Why does list have no 'get' method?

Michael Spencer mahs at telcopartners.com
Thu Feb 7 18:51:36 CET 2008


Wildemar Wildenburger wrote:
> Arnaud Delobelle wrote:
>> Personally, between
>>
>> * foo if foo else bar
>> * foo or bar
>>
>> I prefer the second. Maybe it could be spelt
>>
>> * foo else bar ?
>>
> How about
> 
> val = foo rather than bar
> 
> If that is not clear and obvios, I don't know what is.  ;)
> 
> /W
Excellent suggestion, and obviously its semantics should be:

   val = foo if bar else foo

and so, some might argue for:

   val = foo despite bar

which would allow more aggressive short-circuiting.  However, I'm not sure how 
useful this is in practice.

M







More information about the Python-list mailing list