[Python-ideas] PEP 428 - object-oriented filesystem paths

T.B. bauertomer at gmail.com
Sat Oct 13 17:29:54 CEST 2012



On 2012-10-13 12:06, Antoine Pitrou wrote:
> Le samedi 13 octobre 2012 à 19:47 +1000, Nick Coghlan a écrit :
>> The problem is that "Windows path" and "Posix path" aren't really
>> accurate. There are a bunch of degrees of freedom, which is *exactly*
>> the problem the context pattern is designed to deal with without a
>> combinatorial explosion of different types or mixins.
>>
>> The "how is the string format determined?" aspect could be handled
>> with separate methods, but how do you do case insensitive comparisons
>> of paths on posix systems?
>
> The question is: why do you want to do that?
> I know there are a limited bunch of special cases where Posix filesystem
> paths may be case-insensitive, but nobody really cares about them today,
> and I don't expect many people to bother tomorrow. Playing with
> individual parameters of path semantics sounds like a theoretical bother
> more than a practical one.
>

If you want do that, and that is a big if, it might be better to give 
keywords arguments to Path(), so that the class signature would look like:

class Path:
     def __init__(self, *args, sep=os.path.sep, 
casesensitive=os.path.casesensitive, expanduser=False)...

This will make PosixPath and WindowsPath a partial class with certain 
keywords arguments filled in.

Notice that os.path.casesensitive is not (yet) present in Python.

Regards,
TB



More information about the Python-ideas mailing list