A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://mail.python.org/pipermail/python-dev/2006-January/060213.html below:

Dev] / as path join operator (was: Re: The path module PEP)

[Python-Dev] / as path join operator (was: Re: The path module PEP)Gareth McCaughan gmccaughan at synaptics-uk.com
Mon Jan 30 14:56:44 CET 2006
Steven Bethard wrote:

> My only fear with the / operator is that we'll end up with the same
> problems we have for using % in string formatting -- the order of
> operations might not be what users expect.  Since join is conceptually
> an addition-like operator, I would expect:
> 
>     Path('home') / 'a' * 5
> 
> to give me:
> 
>     home/aaaaa
> 
> If I understand it right, it would actually give me something like:
> 
>     home/ahome/ahome/ahome/ahome/a

Is there any very deep magic that says / is the One True Operator
to use for this, given that there's to be an operator for it? For
instance, & has lower correct precedence (so that Path('home') & 'a'*5
does something less unexpected), and doesn't look quite so much
as if it denotes arithmetic, and avoids semantic interference
from the idea that "/" should divide things or make them smaller.
(Though, for what it's worth, I think sticking another subdirectory
onto a path *is* dividing and making smaller: think of a path as
representing a subtree.) You do lose the pun on the Unix path separator,
which is a shame.

-- 
g

More information about the Python-Dev mailing list

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4