os.readlink() doco snafu?
Fredrik Lundh
fredrik at pythonware.com
Wed Aug 20 15:40:55 EDT 2008
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>
More information about the Python-list
mailing list