[path-PEP] Path inherits from basestring again

Peter Hansen peter at engcorp.com
Mon Jul 25 11:19:25 EDT 2005


Michael Hoffman wrote:
> Reinhold Birkenfeld wrote:
>> Tony Meyer wrote:
>>> Do people really like using __div__ to mean join?  
>>
>> I'm not too happy with it, too, but do we have alternatives? ...
>> Of course, one can use joinwith() if he doesn't like '/'.
> 
> I've used the path module pretty extensively and always use joinpath(). 
> Personally, I'm -0 on __div__, but I suppose if anyone here claimed to 
> have used in the past, rather than it just being some novelty that might 
> be a good idea, that would be good enough for keeping it.

I've tried it both ways, and ended up accepting / as a useful and clean 
approach, though as a general rule I find operator-overloading to be 
fairly hideous and to lead to Perlish code.  This one I resisted for a 
while, then found it fairly pleasant, making it perhaps the exception to 
the rule...

Perhaps it's just that in code that builds paths out of several 
components, it seemed quite straightforward to read when it used / 
instead of method calls.

For example, from one program:

    scripts = userfolder / scriptfolder
    scriptpath = scripts / self.config['system']['commandfile']

instead of what used to be:

    scripts = userfolder.joinpath(scriptfolder)
    scriptpath = scripts.joinpath(self.config['system']['commandfile'])

Even so I'm only +0 on it.

-Peter



More information about the Python-list mailing list