[path-PEP] Path inherits from basestring again

Bengt Richter bokr at oz.net
Mon Jul 25 16:30:34 EDT 2005


On Mon, 25 Jul 2005 11:19:25 -0400, Peter Hansen <peter at engcorp.com> 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.

(;-) How about a __use_adjacent_operand__ op with simple expression
white-space-separated adjacency implying it? Then you could leave out the '/'
and write

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

Hm, if you made that __hadjacent__ for horizontal whitespace, and __vadjacent__ if the
white space included '\n', then you could form even two-dimensional arrays without all that
of punctuation (except that you'd need an explicit ending ';' for the above or () most likely for 2D)

    (funnyarray()
        1 2 3
        4 5 6
    )

BTW, more OT, wouldn't '|' be more platform-neutral as the joining operator?

;-)

Regards,
Bengt Richter



More information about the Python-list mailing list