os.path.walk arg

Matt Gerrans mgerrans at mindspring.com
Thu Mar 13 11:52:22 EST 2003


I like to do my path walking from a class, so that argument is always self,
like so, in a method:

   os.path.walk( startPath, MyPathWalkerClassName.__walker, self )


"Afanasiy" <abelikov72 at hotmail.com> wrote in message
news:cec17vkbjrc0kfdb4v071tqrmjkmn66fkn at 4ax.com...
> What is the purpose of arg in os.path.walk(path, visit, arg) ?
>
> The documentation states :
>
> Calls the function visit with arguments (arg, dirname, names) for each
> directory in the directory tree rooted at path (including path itself, if
> it is a directory). The argument dirname specifies the visited directory,
> the argument names lists the files in the directory (gotten from
> os.listdir(dirname)). The visit function may modify names to influence the
> set of directories visited below dirname, e.g., to avoid visiting certain
> parts of the tree. (The object referred to by names must be modified in
> place, using del or slice assignment.)
>
> I assume I can pass arguments to my visitor function, so I specify None.
> Upon doing so I wonder why that would not be a default and am reminded
> of the magic of specifying so many NULL's in Win32 API calls from C.






More information about the Python-list mailing list