[path-PEP] Path inherits from basestring again

Meyer, Tony T.A.Meyer at massey.ac.nz
Wed Jul 27 06:37:45 CEST 2005


>>> Do people really like using __div__ to mean join?  
>>
>> I think the '+' is used as a join for both strings and lists, so it 
>> would probably be the better choice as far as consistency with the 
>> language is concerned.
>
> The issue with that is that as long as we are subclassing
> strings, the + is already defined for a useful operation
> and the subclass probably shouldn't be changing the way that works.

But a Path isn't a string, it's string-like.  I presume (but am too lazy to check) that at the moment using '+' on two Paths gives a Path that concatenates the __str__ versions of the Paths, like:

>>> Path("/foo/bar") + Path("/cat/dog")
Path("/foo/bar/cat/dog")

I can see that this would make sense in some situations, but ISTM that it would make a great deal more sense (and be much more intuitive) to have concatenation include the separator character (i.e. be join).

=Tony.Meyer



More information about the Python-list mailing list