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 woparry
Recipients Thomas Fenzl, babou, r.david.murray, woparry
Date 2013-05-21.17:13:32
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1369156413.22.0.357792195074.issue17545@psf.upfronthosting.co.za>
In-reply-to
Content
I suggest that this is a documentation issue.

I have seen three classes of functions is os and os.path
i - those which operate on path names only (os.path.join, os.path.dirname, etc) and do not depend on the state of the file system. Since these are string manipulation functions, they treat '' as the empty string.
ii - those which turn path names into valid paths via knowledge of the state of the file system (os.path.abspath, os.path.normpath, etc). These treat '' as an empty relative path and thus equivalent to the current directory.
iii - those which operate on valid paths only and thus depend on the state of the file system (os.listdir, os.stat, os.path.relpath, os.path.exists, etc). '' is not a valid path so these functions throw an exception.

The documentation should clearly state which class a function belongs to. I will provide a patch sometime this week.

os.walk is an odd duck - it has class iii behaviour except that it returns an empty iterator instead of raising an exception. Note that it still distinguishes between '' (invalid path) and '.' (current directory) and so is not a good reason to change os.listdir:

>>> [x for x in os.walk('')]
[]
>>> [x for x in os.walk('.')]
[('.', [], [])]

in an empty directory.
History
Date User Action Args
2013-05-21 17:13:33woparrysetrecipients: + woparry, r.david.murray, Thomas Fenzl, babou
2013-05-21 17:13:33woparrysetmessageid: <1369156413.22.0.357792195074.issue17545@psf.upfronthosting.co.za>
2013-05-21 17:13:33woparrylinkissue17545 messages
2013-05-21 17:13:32woparrycreate