473,708 Members | 2,355 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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(pat h)
result
'bar'
>>abspath = os.path.join(os .path.dirname(p ath), 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 1728
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(pat h)
result
'bar'
>>>abspath = os.path.join(os .path.dirname(p ath), result)
os.path.isab s(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
928
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 dateinbox = TextBox1.text sportsel = Sport.text %> <asp:TextBox id="TextBox1" runat="server"></asp:TextBox> <asp:RadioButton id="sport1" GroupName="Sport" text="mlb" value="mlb"
2
1227
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 install SQL Server Express B3 I can't get the client side tools to install (the command lines). The server is apperantly working, but I can't log into it because I don't get any of the clients. How do I fix this?
3
1562
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 from it. To get the SDK doco I have to startup IE on the "...\SDK\StartHere.htm", and then click the link to the SDK doco. The item linked to is "javascript:Link('ms-help://MS.NETFrameworkSDKv1.1/sdkstart/html/sdkstart.htm'". I've tried every...
9
2138
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 online db. We run an inhouse query to collect info from online db and update
4
5278
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 user will hopefully be able to use to change the sort order of the records on the same form. Here's the code for the "OnChange" event, minus the DoCmd.Repaint.Object Line:
7
7494
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 = Request.QueryString; string rqsday; rqsday = (System.String.Format("{0:dddd}",rqs)) ;
4
1325
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 compile, I get /bin/snafu.dll and /bin/es-MX/snafu.resources.dll. When I run it on my workstation, everything is fine; I can see both the English and Spanish versions. However, when I copy the application to another machine, I can no longer see the...
4
6994
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 it is relative, it may be converted to an absolute pathname using os.path.join(os.path.dirname(path), result). Availability: Macintosh, Unix.
0
8792
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8699
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9293
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9163
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9064
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9003
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7932
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
2
2508
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2097
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.