[Python-Dev] Alternative path suggestion

Nick Coghlan ncoghlan at gmail.com
Thu May 4 15:55:34 CEST 2006


Stefan Rank wrote:
>> I suggest storing the first element separately from the rest of the path. The 
>> reason for suggesting this is that you use 'os.sep' to separate elements in 
>> the normal path, but *not* to separate the first element from the rest.
> 
> I want to add that people might want to manipulate paths that are not 
> for the currently running OS. Therefore I think the `sep` should be an 
> attribute of the "root" element.

I meant to mention that. The idea I had was for normal path objects to use 
os.sep and os.extsep (so they can be pickled and unpickled successfully 
between platforms), and then have a mechanism that allowed a platform specific 
path to be selected based on the desired platform (i.e. one of the possible 
values of os.name: 'posix', 'nt', 'os2', 'mac', 'ce' or 'riscos').

My inclination was to have a PlatformPath subclass that accepted 'os', 'sep' 
and 'extsep' keyword arguments to the constructor, and provided the 
appropriate 'sep' and 'extsep' attributes (supplying 'os' would just be a 
shortcut to avoid specifying the separators explicitly).

That way the main class can avoid being complicated by the relatively rare 
need to operate on another platform's paths, while still supporting the ability.

Cheers,
Nick.

-- 
Nick Coghlan   |   ncoghlan at gmail.com   |   Brisbane, Australia
---------------------------------------------------------------
             http://www.boredomandlaziness.org


More information about the Python-Dev mailing list