(Jan-09-2018, 07:44 AM)Gribouillis Wrote:so this affects the generator state? how? what does the [:] on the LHS do? can i delete a directory from the directory list to have it not descend that one?(Jan-09-2018, 05:50 AM)Skaperen Wrote: i find no means to modify the list of subdirectories that it uses to descend down to the next level, such as sorting them or removing selected subdirectoriesIn principle, you can do this by changing the contents of the subdirectories list, for example
import os for root, subdirs, files in os.walk('foo'): subdirs[:] = sorted(subdirs) # sorts the subdirs subdirs[:] = [d for d in subdirs if not d.startswith('tmp')] # remove some subdirs print(root, subdirs)
Tradition is peer pressure from dead people
What do you call someone who speaks three languages? Trilingual. Two languages? Bilingual. One language? American.
What do you call someone who speaks three languages? Trilingual. Two languages? Bilingual. One language? American.