os.path.realpath() and os.path.abspath()

Discussion in 'Python' started by Jurko Gospodnetiæ, Jan 11, 2011.

  1. Hi all.

    os.path.realpath() documentation states that it returns a 'canonical'
    path. Does that infer that it returns an absolute path?

    I have not found seen any implementation that does not return an
    absolute path, but can this be counted on? Or should we use
    os.path.abspath(os.path.realpath(x)) when we want to convert x to its
    full/canonical name?

    Best regards,
    Jurko Gospodnetiæ
    Jurko Gospodnetiæ, Jan 11, 2011
    #1
    1. Advertising

  2. Jurko Gospodnetiæ

    Adam Skutt Guest

    On Jan 11, 6:35 am, Jurko Gospodnetiæ <>
    wrote:
    >    Hi all.
    >
    >    os.path.realpath() documentation states that it returns a 'canonical'
    > path. Does that infer that it returns an absolute path?
    >


    A canonical path is supposed to be absolute and at least Python 2.7.1
    ensures that is the case.

    Historically, some versions of the UNIX syscall (Solaris in
    particular) have not always returned absolute paths, but I believe
    this is no longer the case and was a very long standing bug (though I
    may be mistaken).

    Adam
    Adam Skutt, Jan 12, 2011
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Peng Yu
    Replies:
    0
    Views:
    445
    Peng Yu
    Oct 31, 2009
  2. Peng Yu
    Replies:
    0
    Views:
    527
    Peng Yu
    Oct 31, 2009
  3. Chris Rebert

    Re: os.path.realpath(path) bug on win7 ?

    Chris Rebert, Jan 6, 2013, in forum: Python
    Replies:
    2
    Views:
    135
    iMath
    Jan 6, 2013
  4. iMath
    Replies:
    0
    Views:
    91
    iMath
    Jan 6, 2013
  5. Victor Stinner

    Re: os.path.realpath(path) bug on win7 ?

    Victor Stinner, Jan 6, 2013, in forum: Python
    Replies:
    2
    Views:
    124
    iMath
    Jan 7, 2013
Loading...

Share This Page