strange interaction between open and cwd
Grant Edwards
invalid at invalid.invalid
Mon May 3 10:24:20 EDT 2010
On 2010-05-03, 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'?
The current directory has an entry named '..' that points to the
parent directory.
> i'm assuming python must initially use getcwd() internally to do
> this,
Nope. Python just passes the string '../abc.txt' to libc's open()
function, and that in turn passes it on to the Unix/Linux open()
syscall, when follows the link in the current working directory named
'..'.
> 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?
None of this has anything at all to do with Python.
--
Grant Edwards grant.b.edwards Yow! I didn't order any
at WOO-WOO ... Maybe a YUBBA
gmail.com ... But no WOO-WOO!
More information about the Python-list
mailing list