Py3K idea: why not drop the colon?

Steve Holden steve at holdenweb.com
Fri Nov 10 13:39:07 EST 2006


Bjoern Schliessmann wrote:
> Michael Hobbs wrote:
> 
>> That is, assume that the expression ends at the colon, not at the
>> newline. That would make this type of statement possible:
>>     if color == red or
>>       color == blue or
>>       color == green:
>>         return 'primary'
>> Right now, such a statement would have to be spelled thus:
>>     if color == red or \
>>       color == blue or \
>>       color == green:
>>         return 'primary'
>> or
>>     if (color == red or
>>       color == blue or
>>       color == green):
>>         return 'primary'
> 
> What about
> 
> if color == red or blue or green:
>     return 'primary'
> 
> :)
> 
> Really, I think it'd be more mess to let the if statement's end only
> depend on ":". I think there could arise situations that are messy
> to debug. If I need multiple lines I prefer the parentheses.
> 
I still prefer

   if color in (red, blue, green):
     ...

regards
  Steve
-- 
Steve Holden       +44 150 684 7255  +1 800 494 3119
Holden Web LLC/Ltd          http://www.holdenweb.com
Skype: holdenweb       http://holdenweb.blogspot.com
Recent Ramblings     http://del.icio.us/steve.holden




More information about the Python-list mailing list