Sorry for the horrible title, it's very hard to explain.
I have this code:
def get_all_zips(path):
zips = []
path_encode = os.fsencode(path)
for file in os.listdir(path_encode):
filename = os.fsdecode(file)
if filename.endswith(".zip") or filename.endswith(".rar"):
zips.append(os.path.join(path, filename))
continue
return zips
def process(zipfiles):
print(zipfiles)
for file in zipfiles:
extract(file, destination)
# Definitely code I wrote and not copied from stack overflow verbatim.
def chunks(lst, n):
for i in range(0, len(lst), n):
yield lst[i:i + n]
zipfiles_chunks = list(chunks(get_all_zips(staging_dir), math.ceil(len(get_all_zips(staging_dir)) / 2)))
thread1 = threading.Thread(target=process, args=zipfiles_chunks[0])
thread1.start()
thread1.join()
zipfiles_chunks is equal to: [['./staging/zip1.zip'], ['./staging/zip2.zip']]
So, zipfiles_chunks[0] should be a list that contains ./staging/zip1.zip as an element, which it is if I print it. But when I print it in the method process it prints out what is equivalent to zipfiles_chunks[0][0]. It's not a list but a string, what should be zipfiles[0] in the method. What gives?