[path-PEP] Path inherits from basestring again

Reinhold Birkenfeld reinhold-birkenfeld-nospam at wolke7.net
Sun Jul 24 11:49:39 EDT 2005


Michael Hoffman wrote:
> Reinhold Birkenfeld wrote:
> 
>> * __iter__() iterates over the parts().
>> * the following methods raise NotImplemented:
>>   capitalize, expandtabs, join, splitlines, title, zfill
> 
> Why? They *are* implemented. I do not understand this desire to wantonly 
> break basestring compatiblity for the sake of breaking compatibility.
>
> Once you break compatibility with basestring you can no longer use a 
> path anywhere that you could have used a str or unicode before. With 
> compatibility broken, the only possible supported way of passing paths 
> to third-party functions will be to cast the path with 
> path.__bases__[0](mypath) before passing it anywhere else. You can't 
> even use str() because you don't know what the base class of the path 
> is. What a pain.
> 
>  From the original path.py documentation:
> 
> """
> os.path.join doesn't map to path.join(), because there's a string method 
> with that name. Instead it's path.joinpath(). This is a nuisance, but 
> changing the semantics of base class methods is worse. (I know, I tried 
> it.) The same goes for split().
> """
> 
> It ain't broke. Please stop breaking it.

Okay. While a path has its clear use cases and those don't need above methods,
it may be that some brain-dead functions needs them.

Reinhold



More information about the Python-list mailing list