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

Nick Coghlan ncoghlan at gmail.com
Sat Oct 13 18:52:18 CEST 2012


On Sun, Oct 14, 2012 at 2:28 AM, Antoine Pitrou <solipsis at pitrou.net> wrote:
>> You can add as many new flavours as you want, and it's only one class
>> per flavour rather than up to 3 (the flavour itself, the pure variant
>> and the concrete variant).
>
> Yes, you can. That doesn't preclude offering separate classes by
> default, though :-)

Factory functions would make more sense to me than separate classes -
they're not really a different type, they're the same type using a
different strategy for the OS dependent bits.

>> This class hierarchy is also more amenable to the introduction of
>> MutablePath as a second subclass of PurePath - a path variant with
>> mutable properties still sounds potentially attractive to me (over a
>> wide variety of return-a-modified-copy methods for various cases).
>
> I'm very cold on offering both mutable on non-mutable paths. That's just
> complicated and confusing. Since an immutable type is very desireable
> for use in associative containers, I think immutability is the right
> choice.

Sure, if we're only offering one of them, then immutable is definitely
the right choice. However, I think this is analogous to the bytes vs
bytearray distinction - while bytes objects are more useful in
general, using the mutable bytearray when appropriate is vastly
superior to slicing and copying bytes objects.

Cheers,
Nick.

-- 
Nick Coghlan   |   ncoghlan at gmail.com   |   Brisbane, Australia



More information about the Python-ideas mailing list