Why does list have no 'get' method?
Michael Spencer
mahs at telcopartners.com
Thu Feb 7 12:51:36 EST 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