[Python-Dev] os.path.dirname misleading?
Wed, 12 Mar 2003 10:54:57 -0600
Kevin> However, to get what I would consider correct behavior based on
Kevin> the function name, the code would need to be:
Kevin> def dirname(p):
Kevin> """Returns the directory component of a pathname"""
Kevin> if isdir(p):
Kevin> return p
Kevin> return split(p)
No can do. On my Mac I could execute:
>>> import ntpath
>>> print ntpath.dirname("C:\\system\\win32")
Calling isdir() is not an option.
Taken another way, "/usr/bin" is a path to a file, so "/usr" is its
directory component. and "bin" is its basename:
That "/usr/bin" happens to also be a directory is beside the point.