strange interaction between open and cwd
Baz Walter
bazwal at ftml.net
Mon May 3 13:45:31 EDT 2010
On 03/05/10 18:12, Grant Edwards wrote:
> On 2010-05-03, Baz Walter<bazwal at ftml.net> wrote:
>>> 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.
>>
>> yes, that's exactly what i was trying to demonstrate in my OP. i can
>> use python to open a file; but under certain circumstances, there
>> seems to be no guarantee that i can then use python to locate that
>> file in the filesystem.
>
> Exactly.
>
> In your example, it's simply not possible to determine the file's
> absolute path within the filesystem given the relative path you
> provided.
>
> You requested something that wasn't possible. It failed. What do you
> think should have happened?
path = '../abc.txt'
os.path.realpath(path) -> "OSError: [Errno 2] No such file or directory"
therefore:
open(path) -> "IOError: [Errno 2] No such file or directory"
i think that if the first of these seemingly "impossible" requests
fails, it is reasonable to expect that the second one also fails. but
the second one (sometimes) doesn't.
i think they should always either both succeed, or both fail.
More information about the Python-list
mailing list