Voting for PEP 308 (was Re: For review: PEP 308 - If-then-else expression)

Tim Hochberg tim.hochberg at ieee.org
Tue Feb 11 13:47:15 EST 2003


Hans Nowak wrote:
> I wrote:
> 
>> Laura Creighton wrote:
>>
>>> Most of the people who don't care will also not be posting.  Or
>>> voting. They're probably not reading comp.lang.python, either.  I
>>> remember when 2.0 came out and people found out about string methods.
>>> A whole bunch of them came back to post articles about how they
>>> thought the new join syntax was really awful and ugly.  They only
>>> cared after it got in, but enough to complain a lot.
>>
>>
>>
>> Hmm, what if bools grew an if() method?  We could then write:
>>
>>   z = (x == y).if(whentrue, whenfalse)
>>
>> This strikes me as much more elegant than the other proposals.
>>
>> (ducking for cover, etc :-)
> 
> 
> Or rather, to be more in the spirit of the PEP and the join() method, 
> maybe it should be:
> 
>   z = whentrue.if(cond, whenfalse)

This is actually exactly opposite to the spirit of the join method. When 
the various possible forms for the join method were being debated, the 
sequence.join(string) method lost out to the string.joing(sequence) 
method precisely becaause all sequences would have to grow a join method 
to participate, whereas with the formthat was actually adopted only the 
string method needs a join method and anything that implements the 
sequence protocol gets to play for free.

> Of course, all objects would have to grow the if() method for this. :-)

As I was saying...

-tim





More information about the Python-list mailing list