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> else: Kevin> return split(p)[0] No can do. On my Mac I could execute: >>> import ntpath >>> print ntpath.dirname("C:\\system\\win32") C:\system 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: >>> os.path.dirname("/usr/bin") '/usr' >>> os.path.basename("/usr/bin") 'bin' That "/usr/bin" happens to also be a directory is beside the point. Skip
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4