os.path and Path

Steven D'Aprano steve+comp.lang.python at pearwood.info
Thu Jun 16 12:41:50 EDT 2011


On Thu, 16 Jun 2011 09:16:22 -0700, Ethan Furman wrote:

> Steven D'Aprano wrote:
>> If Path is intended to be platform independent, then these two paths
>> could represent the same location:
>> 
>> 'a/b/c:d/e'  # on Linux or OS X
>> 'a:b:c/d:e'  # on classic Mac pre OS X
>> 
>> and be impossible on Windows. So what's the canonical path it should be
>> converted to?
> 
> Are these actual valid paths?  I thought Linux used '/' and Mac used
> ':'.

Er, perhaps I wasn't as clear as I intended... sorry about that.

On a Linux or OS X box, you could have a file e inside a directory c:d 
inside b inside a. It can't be treated as platform independent, because 
c:d is not a legal path component under classic Mac or Windows.

On a classic Mac (does anyone still use them?), you could have a file e 
inside a directory c/d inside b inside a. Likewise c/d isn't legal under 
POSIX or Windows.

So there are paths that are legal under one file system, but not others, 
and hence there is no single normalization that can represent all legal 
paths under arbitrary file systems.


-- 
Steven



More information about the Python-list mailing list