How to test if two strings point to the same file or directory?

Leif K-Brooks eurleif at ecritters.biz
Sun Dec 17 00:28:22 EST 2006


Tim Chase wrote:
>>> Comparing file system paths as strings is very brittle.
>>
>> Why do you say that? Are you thinking of something like this?
>>
>> /home//user/somedirectory/../file
>> /home/user/file
> 
> Or even
> 
>     ~/file

~ is interpreted as "my home directory" by the shell, but when it's used 
in a path, it has no special meaning. open('~/foo.txt') tries to open a 
file called foo.txt in a subdirectory of the current directory called '~'.



More information about the Python-list mailing list