strange interaction between open and cwd

Grant Edwards invalid at invalid.invalid
Mon May 3 10:55:16 EDT 2010


On 2010-05-03, Baz Walter <bazwal at ftml.net> wrote:
> On 03/05/10 14:56, Chris Rebert wrote:
>>> but how does '..' get resolved in the relative path '../abc.txt'? i'm
>>> assuming python must initially use getcwd() internally to do this, and then
>>> if that fails it falls back on something else. but what is that something
>>> else? is it something that is reproducible in pure python?
>>
>> I would think that the OS system call, not Python itself, does the
>> relative->absolute conversion.
>
> so there is a discrepancy between some of the std library path functions 
> (like realpath, getcwd, abspath) and the built-in open function.

Not really.  There is a discrepancy between your perception and
expectations and the way the Unix filesystem works.

> there are files which can be opened for which it is impossible to
> resolve their full paths (on some platforms).

Sort of.  The file in question _has_ a full path, you just can't tell
what it is based on the path you used to open it.

-- 
Grant Edwards               grant.b.edwards        Yow! I smell a RANCID
                                  at               CORN DOG!
                              gmail.com            



More information about the Python-list mailing list