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

John Machin sjmachin at lexicon.net
Sat Dec 16 20:38:14 EST 2006


Tim Chase wrote:
> > Comparing file system paths as strings is very brittle. Is there a
> > better way to test if two paths point to the same file or directory
> > (and that will work across platforms?)
>
> 	os.path.samefile(filename1, filename2)
> 	os.path.sameopenfile(fileobject1, fileobject2)
> 

Nice try, but they don't "work across platforms".




More information about the Python-list mailing list