W. Owen Parry added the comment:

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.

----------

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue17545>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to