[issue15342] os.path.join behavior
Yongzhi Pan
report at bugs.python.org
Mon Jul 16 06:29:29 CEST 2012
Yongzhi Pan <fossilet at users.sourceforge.net> added the comment:
I suggest append "An empty last part will result in a path that ends with a separator" or something similar to the docstring, though it is already in the HTML documentation.
Suppose someone does this like me:
In [10]: join('a', sep)
Out[10]: '/'
He must be surprised. He has to guess how to append a separator if he does not look at the code, or fiddle around until he finds the soultion.
Given it explained in the docstring, after he sees:
In [10]: join('a', sep)
Out[10]: '/'
He will probably look at the docstring:
In [16]: join?
Type: function
Base Class: <type 'function'>
String Form:<function join at 0x7f053fc93ed8>
Namespace: Interactive
File: /usr/lib/python2.7/posixpath.py
Definition: join(a, *p)
Docstring:
Join two or more pathname components, inserting '/' as needed.
If any component is an absolute path, all previous path components
will be discarded. An empty last part will result in a path that
ends with a separator.
Ok, he immediately knows he has to supply an empty string instead of a separator.
----------
_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue15342>
_______________________________________
More information about the Python-bugs-list
mailing list