[Python-ideas] except expression

spir denis.spir at gmail.com
Thu Feb 13 12:27:13 CET 2014


On 02/13/2014 12:10 PM, Ben Finney wrote:
> spir <denis.spir at gmail.com> writes:
>
>> I think the right way is not to call the function at all, but to check
>> it. Conceptually:
>>
>>    if col.is_empty():
>>        handle_special_case()
>>    else:
>>        handle_standard_case()
>
> Or, better from two perspectives (“empty” should normally entail
> “evaluates to boolean false”; and, the normal case should be the first
> branch from the “if”)::
>
>      if col:
>          handle_standard_case()
>      else:
>          handle_empty_case()

You are right (I always forget that empty means false in python, in a logical 
context, which i don't find obvious at all --I wonder if any other lang follows 
this choice).

d


More information about the Python-ideas mailing list