strange interaction between open and cwd
Dave Angel
davea at ieee.org
Mon May 3 10:49:16 EDT 2010
Baz Walter 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?
>
>
os.path.dirname() doesn't care about whether a path actually represents
a location on disk. It just parses the string.
If I were processing the .., that's what I'd use to normalize it.
DaveA
More information about the Python-list
mailing list