i currently want to improve a python script I wrote once.
In it the structure is roughly like this:
def x(args):
for root, dirs, files in os.walk(args):
do_something_that_changes_the_directory_structure()
for root, dirs, files in os.walk(args):
do_someting_with_that_changed_directory()
The problem is that i change the directory structure and have to re-read that structure to do something with it. Is it possible to do this with only one for loop? I thougth about while loops but after thinking about it I don’t think that works!
You should update
dirsandfilesaccording to the changes you’ve made to your folder. For example: