Problem with Python on MAC OSX

Reinhold Birkenfeld reinhold-birkenfeld-nospam at wolke7.net
Tue Jun 29 05:27:57 EDT 2004


edadk wrote:
> Hi
> 
> I have problem with Python on MAC OSX. The following code documents it
> 
> strib:~ eda$ pwd
> /home/eda
> strib:~ eda$ python
> Python 2.3 (#1, Sep 13 2003, 00:49:11)
> [GCC 3.3 20030304 (Apple Computer, Inc. build 1495)] on darwin
> Type "help", "copyright", "credits" or "license" for more information.
>>>> import os
>>>> print os.getcwd()
> /private/home/eda
>>>>
> 
> Note I would have expected
> 
> print os.getcwd()
> 
> to print
> 
> /home/eda
> 
> Note that
> 
>>>> os.system('echo $PWD')
> /home/eda
> 0
> 
> Of course /home/eda is a symbolic link to /private/home/eda. Is this a
> bug or a feature? Is there a good way to work around it?

I can see the same behaviour here under Linux.

There is no way to work around that, only using the PWD environment
variable set by the shell. The standard POSIX function getcwd(), which
Python's os.getcwd utilizes, returns an absolute path to the current
directory, that is, without any symlinks in it. The shell, in the
contrary, keeps track of what symlinked directories you enter, and can
tell you these.

But why don't you like the result? The directories pointed to by both
paths are the same...

Reinhold

-- 
Wenn eine Linuxdistribution so wenig brauchbare Software wie Windows
mitbrächte, wäre das bedauerlich.  Was bei Windows der Umfang eines
"kompletten Betriebssystems" ist, nennt man bei Linux eine Rescuedisk.
  -- David Kastrup in de.comp.os.unix.linux.misc



More information about the Python-list mailing list