469,286 Members | 2,442 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,286 developers. It's quick & easy.

os.readlink() doco snafu?

JBW
English is my first language, but I doesn't be very good at it.

I was trying to endow my symlinked python module with the ability to
divine where it actually resides when I came across os.readlink(),
documented at http://docs.python.org/lib/os-file-dir.html

I'm not sure readlink() lives up to its documentation. To wit:

$ touch bar # Create an empty file
$ ln -s bar foo # And a symlink to it.
$ python
Python 2.5.1 <... Herald "the snitch" Redacted ...>
Type "help", "copyright", "credits" or "license" for more information.
>>import os, os.path
path = "foo"
result = os.readlink(path)
result
'bar'
>>abspath = os.path.join(os.path.dirname(path), result)
os.path.isabs(abspath)
False
>>abspath
'bar'

The result makes sense, but it belies the documentation. Should I report
this? Or is there another plausible interpretation?
Aug 20 '08 #1
2 1637
JBW wrote:
I'm not sure readlink() lives up to its documentation. To wit:

$ touch bar # Create an empty file
$ ln -s bar foo # And a symlink to it.
$ python
Python 2.5.1 <... Herald "the snitch" Redacted ...>
Type "help", "copyright", "credits" or "license" for more information.
>>>import os, os.path
path = "foo"
result = os.readlink(path)
result
'bar'
>>>abspath = os.path.join(os.path.dirname(path), result)
os.path.isabs(abspath)
False
>>>abspath
'bar'

The result makes sense, but it belies the documentation. Should I report
this? Or is there another plausible interpretation?
the part about joining with dirname(path) assumes that you pass in an
absolute path to the readlink function.

</F>

Aug 20 '08 #2
Fredrik Lundh wrote:
JBW wrote:
>I'm not sure readlink() lives up to its documentation. ...
The result makes sense, but it belies the documentation. Should I report
this? Or is there another plausible interpretation?

the part about joining with dirname(path) assumes that you pass in an
absolute path to the readlink function.
That documentation should probably say, "if it is relative, it may be
converted to a pathname valid from the current working directory using
...."

-Miles
Aug 20 '08 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

reply views Thread by Chumley the Walrus | last post: by
2 posts views Thread by ayende | last post: by
3 posts views Thread by Javaman59 | last post: by
9 posts views Thread by James Butler | last post: by
4 posts views Thread by Patrick Arkins | last post: by
7 posts views Thread by .Net Sports | last post: by
4 posts views Thread by Robert Dobson | last post: by
4 posts views Thread by Giampaolo Rodola' | last post: by
1 post views Thread by CARIGAR | last post: by
reply views Thread by zhoujie | last post: by
reply views Thread by suresh191 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.