Your IDE is incorrect, in Python 2 iterators (including generators like os.walk()
) do have a .next()
method.
You can also use the built-in next()
function:
samples_list = next(os.walk(directory))[1]
I suspect the IDE mismatched the generator against the collections.Iterable
ABC, while generators are Iterator
s too.