473,414 Members | 1,781 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,414 software developers and data experts.

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 1714
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Chumley the Walrus | last post by:
I'm trying to parse the selected value from a group of radiobuttons, but the below code for the radio buttons doesnt work, whereas the one for the text box does. <% dim dateinbox, sportsel...
2
by: ayende | last post by:
I've installed and unistalled SQL Server 2000 and MSDE on my computer as I needed it (my machine is a development machine). I've tested SQL Server B2 and then uninstalled it, now when I try to...
3
by: Javaman59 | last post by:
Hi, This is a question for DOS programmers, if there are any here... :) I'm successfully using the command line for c# programming, except for one thing - I can't startup the SDK documentation...
9
by: James Butler | last post by:
Our setup: Online db: MySQL Inhouse db: MS Access 97 with MySQL tables linked via ODBC Our issue: Almost every field updates successfully, except one. A scenario: Information is written to...
4
by: Patrick Arkins | last post by:
I have a Main form (named FRM_Main in the Forms Window) with a Subform (named FRM_User_Search in the Forms window, form_User_Search on Forms_Main). FRM_User_Search has a combo-box (cboSort) the...
7
by: .Net Sports | last post by:
Before processing my data in a datagrid, I need to parse the day of the week (which will be my 'rqsday' variable) from a string that comes over on a querystring: string rqs =...
4
by: Robert Dobson | last post by:
I've run into a rather perplexing problem and unfortunately nobody has yet been able to help me resolve it. I have built an application that supports both English and Spanish text. When I...
4
by: Giampaolo Rodola' | last post by:
I was reading os.readlink doc which says: readlink( path) Return a string representing the path to which the symbolic link points. The result may be either an absolute or relative pathname; if...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.