[Python-ideas] PEP 428 - object-oriented filesystem paths
Antoine Pitrou
solipsis at pitrou.net
Sat Oct 13 12:06:34 CEST 2012
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.
A possibility would be to expose the Flavour classes, which until now
are an internal implementation detail. That would first imply better
defining their API, though. Then people could write e.g.:
class PosixCaseInsensitiveFlavour(pathlib.PosixFlavour):
case_sensitive = False
class MyPath(pathlib.PosixPath):
flavour = PosixCaseInsensitiveFlavour()
But I would consider it extra icing on the cake, not a requirement for a
Path API.
Regards
Antoine.
--
Software development and contracting: http://pro.pitrou.net
More information about the Python-ideas
mailing list