Basically my question boils down to "What does os.walk
actually return?"
I'm carrying out a simple experiment:
list(os.walk('test_dir'))[0]
yields the following result:
('test_dir', [], ['somefile1', 'somefile2'])
So it does seem that the os.walk function in this case returns a generator of a tuple. I can also write something like this:
for root, dirs, files in os.walk('test_dir'):
pass
but if I, say, do the following:
for root, dirs, files in (item for item in list(os.walk('test_dir'))[0]):
pass
I will get the above-mentioned error: "ValueError: too many values to unpack (expected 3)"
I don't understand why.