This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author akira
Recipients Sung-Yu.Chen, akira, alexey-smirnov, benhoyt, docs@python, ncoghlan, socketpair, ukl, vstinner
Date 2014-07-28.14:16:38
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1406556998.97.0.373868428284.issue12970@psf.upfronthosting.co.za>
In-reply-to
Content
I've updated os.walk() documentation to mention that *dirnames* list
includes symlinks to directories.

To imitate the other two cases:

- treat the symlinks as files:

    for dirpath, dirnames, files in os.walk(top):
        dirs = []
        for name in dirnames:
            (files if islink(join(dirpath, name)) else dirs).append(name)
        dirnames = dirs

- don't include in either of the lists:

    for dirpath, dirnames, files in os.walk(top):
        dirnames[:] = [name for name in dirnames
                       if not islink(join(dirpath, name))]

where islink = os.path.islink and join = os.path.join.

I've uploaded the documentation patch. Please, review.
History
Date User Action Args
2014-07-28 14:16:39akirasetrecipients: + akira, ncoghlan, vstinner, benhoyt, docs@python, socketpair, alexey-smirnov, Sung-Yu.Chen, ukl
2014-07-28 14:16:38akirasetmessageid: <1406556998.97.0.373868428284.issue12970@psf.upfronthosting.co.za>
2014-07-28 14:16:38akiralinkissue12970 messages
2014-07-28 14:16:38akiracreate