Too much code - slicing

Mark Lawrence breamoreboy at yahoo.co.uk
Mon Sep 20 23:07:03 CEST 2010


On 20/09/2010 18:28, Antoon Pardon wrote:
> On Sun, Sep 19, 2010 at 11:30:32PM +0000, Seebs wrote:
>> On 2010-09-19, MRAB<python at mrabarnett.plus.com>  wrote:
>>> On 19/09/2010 22:32, Seebs wrote:
>>>> On 2010-09-19, AK<andrei.avk at gmail.com>   wrote:
>>>>> Because that's what 'if' and 'else' mean.
>>
>>>> My point is, I don't want the order of the clauses in if/else to change.
>>>> If it is sometimes "if<condition>   <true-clause>   else<false-clause>", then
>>>> it should *ALWAYS WITHOUT EXCEPTION* be condition first, then true clause,
>>>> then false clause.  If it's sometimes "if condition true-clause else
>>>> false-clause", and sometimes "true-clause if condition else false-clause",
>>>> that's a source of extra complexity.
>>>
>>> [snip]
>>> Have you read PEP 308? There was a lot of discussion about it.
>>
>> Interesting, in the historical section we see:
>>
>>    The original version of this PEP proposed the following syntax:
>>
>> 	<expression1>  if<condition>  else<expression2>
>>
>> 	The out-of-order arrangement was found to be too uncomfortable
>> 	for many of participants in the discussion; especially when
>> 	<expression1>  is long, it's easy to miss the conditional while
>> 	skimming.
>>
>> But apparently those objections were either unknown or disregarded when
>> the syntax was later adopted.
>
> Not necessarily. Some of us have the impression that Guido deliberatly
> chose an ugly format for the ternary operator. Guido has alwasys been
> against a ternary operator but the requests kept coming. So eventually
> he introduced one. But the impression is that he chose an ugly format
> in the hope of discouraging people to use it.
>

I very much like the format of the Python ternary operator, but I've 
never actually used it myself :)

Cheers

Mark Lawrence.




More information about the Python-list mailing list