A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://mail.python.org/pipermail/python-dev/2003-March/033982.html below:

[Python-Dev] os.path.dirname misleading?

[Python-Dev] os.path.dirname misleading? [Python-Dev] os.path.dirname misleading?Skip Montanaro skip@pobox.com
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>     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