[docs] Looks like there should be walk() instead of listdir()

Eli Bendersky eliben at gmail.com
Mon May 9 15:03:06 CEST 2011

On Tue, May 3, 2011 at 07:39, Victor Varvariuc
<victor.varvariuc at gmail.com>wrote:

> http://docs.python.org/library/os.html#os.walk
> ...
>> By default errors from the listdir()<http://docs.python.org/library/os.html#os.listdir> call
>> are ignored. If optional argument *onerror* is specified, it should be a
>> function; it will be called with one argument, an OSError<http://docs.python.org/library/exceptions.html#exceptions.OSError>
>>  instance.
>> ...
> <http://docs.python.org/library/os.html#os.walk>
> Looks like there should be walk() instead of listdir()

walk() is implemented using listdir(), so I believe the documentation here
is right. Here's the relevant code from os.walk():

        # Note that listdir and error are globals in this module due
        # to earlier import-*.
        names = listdir(top)
    except error, err:
        if onerror is not None:

As you can see, if listdir() throws an exception, it is ignored unless
"onerror" is specified.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/docs/attachments/20110509/dc87d45d/attachment.html>

More information about the docs mailing list