os.path and Path

Ethan Furman ethan at stoneleaf.us
Thu Jun 16 13:18:44 EDT 2011


Steven D'Aprano wrote:
> 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.

Yeah, I was just realizing that about two minutes before I read this 
reply.  Drat.  This also makes your comment about sensible path objects 
more sensible.  ;)

~Ethan~



More information about the Python-list mailing list