Bad docs for os.path.isabs()

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Ben Allfree

    Bad docs for os.path.isabs()

    The docs for os.path.isabs() state:

    isabs( path)

    Return True if path is an absolute pathname (begins with a slash).

    This is false becase os.path.isabs(" C:\\foo") == True

    It should read:

    isabs( path)

    Return True if path is an absolute pathname (begins with a slash or drive
    letter).


  • Bengt Richter

    #2
    Re: Bad docs for os.path.isabs()

    On Sun, 9 Nov 2003 11:32:46 -0800, "Ben Allfree" <benles@bldigit al.com> wrote:
    [color=blue]
    >The docs for os.path.isabs() state:
    >
    > isabs( path)
    >
    >Return True if path is an absolute pathname (begins with a slash).
    >
    >This is false becase os.path.isabs(" C:\\foo") == True
    >
    >It should read:
    >
    > isabs( path)
    >
    >Return True if path is an absolute pathname (begins with a slash or drive
    >letter).[/color]

    While you're at it, better take this into account also ;-)
    [color=blue][color=green][color=darkred]
    >>> import os
    >>> os.path.isabs(" C:\\foo")[/color][/color][/color]
    True[color=blue][color=green][color=darkred]
    >>> os.path.isabs(" C:foo")[/color][/color][/color]
    False[color=blue][color=green][color=darkred]
    >>> os.path.isabs(" \\foo")[/color][/color][/color]
    True

    For that last one, I think you could argue that it's false, since it does not
    absolutely specify what the meaning is in a multi-drive system.

    The whole drive letter file path thing is soo lame it makes me incoherent ;-/

    Regards,
    Bengt Richter

    Comment

    • Peter Hansen

      #3
      Re: Bad docs for os.path.isabs()

      Ben Allfree wrote:[color=blue]
      >
      > The docs for os.path.isabs() state:
      >
      > isabs( path)
      >
      > Return True if path is an absolute pathname (begins with a slash).
      >
      > This is false becase os.path.isabs(" C:\\foo") == True
      >
      > It should read:
      >
      > isabs( path)
      >
      > Return True if path is an absolute pathname (begins with a slash or drive
      > letter).[/color]

      As Bengt says, that revision is still insufficient/incorrect.

      Probably the only way it can really be said is something like
      "returns True if os.path.abspath () would leave the path unchanged".
      (Or some variation on that... i.e. leave the actual specification
      to the nuts-and-bolts of the platform-dependent code, rather than
      trying to rewrite it in English and risk duplication/errors.)

      -Peter

      Comment

      • Peter Hansen

        #4
        Re: Bad docs for os.path.isabs()

        Frank Bechmann wrote:[color=blue]
        >
        > IIRC (I currently have no DOS console at hand) even this is wrong:
        >
        > "Return True if path is not relative to the current working
        > directory."
        >
        > because the case "D:xyz" means a path relative to current path on
        > drive D: which is eventually not the same as the current working
        > directory.[/color]

        You are correct, although the best thing for the world might be
        if we all just pretended you weren't. :-)

        -Peter

        Comment

        Working...