strange interaction between open and cwd

Chris Rebert clp2 at rebertia.com
Mon May 3 09:56:42 EDT 2010


On Mon, May 3, 2010 at 6:49 AM, Baz Walter <bazwal at ftml.net> wrote:
> On 03/05/10 14:18, Chris Rebert wrote:
>> Whether or not /home/baz/tmp/xxx/ exists, we know from the very
>> structure and properties of directory paths that its parent directory
>> is, *by definition*, /home/baz/tmp/ (just chop off everything after
>> the second-to-last slash). I would assume this is what happens
>> internally.
>> How exactly this interacts with, say, moving the directory to a new
>> location rather than deleting it, I don't know; again, it would quite
>> likely be platform-specific.
>
> 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.

Cheers,
Chris
--
Fsck MMW.



More information about the Python-list mailing list