How does os.walk work?
gregpinero at gmail.com
gregpinero at gmail.com
Thu Jun 7 23:53:24 EDT 2007
On Jun 7, 5:13 pm, Gary Herron <gher... at islandtraining.com> wrote:
> Simple: os.walk builds the list to contain all the subdirectories.
> After giving you a chance to modify that list, ow.walk then goes through
> the list (whatever contents it has at that point) and visits any
> subdirectory.
>
> I'd guess your trouble with understanding this has to do with wondering
> how the modified list gets from your code back to os.walk. But in fact
> they are not two separate lists, but one list, passed by reference from
> os.walk into your code.
>
Thanks, that does make sense now.
-Greg
More information about the Python-list
mailing list