Python Doc Problem Example: os.path.split()
Xah Lee, 20050918
Quote from: http://www.python.org/doc/2.4.1/lib/module-os.path.html
split(path)
Split the pathname path into a pair, (head, tail) where tail is the
last pathname component and head is everything leading up to that. The
tail part will never contain a slash; if path ends in a slash, tail
will be empty. If there is no slash in path, head will be empty. If
path is empty, both head and tail are empty. Trailing slashes are
stripped from head unless it is the root (one or more slashes only). In
nearly all cases, join(head, tail) equals path (the only exception
being when there were multiple slashes separating head from tail).
This confusive verbiage is a result of the author's pretention in a
austere style and his failure to think clearly before writing.
Suggested rewrite:
split(path)
returns a pair (dirname,filename), where dirname is the part of
path up to the last slash, and filename is the rest of the string after
the last slash.
Exceptional cases are:
• if path is a single slash (or repeated), then path == dirname and
filename is empty.
• If the “last” slash is repeated, they are treated as one single
slash.
-----------
This post is archived at:
http://xahlee.org/perl-python/python_doc_os_path_split.html
☄