I want to change the following code
for directory, dirs, files in os.walk(directory_1): do_something() for directory, dirs, files in os.walk(directory_2
Here it is using a generator expression with nested fors:
for
a = range(3) b = range(5) ab = (i for it in (a, b) for i in it) assert list(ab) == [0, 1, 2, 0, 1, 2, 3, 4]