[path-PEP] Path inherits from basestring again

Ron Adam rrr at ronadam.com
Tue Jul 26 02:32:17 EDT 2005


Peter Hansen wrote:
> 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

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.

Cheers,
Ron


As for features we don't have yet, you could use an "inerator". 
Something that gets stuff a little bit at a time.

If you combine an iterator with a inerator, you would have a itinerator 
which would be quite useful for managing 'flight-paths'.   ;-)



More information about the Python-list mailing list