[Python-ideas] except expression

Ben Finney ben+python at benfinney.id.au
Thu Feb 13 12:10:16 CET 2014


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()

-- 
 \        “Intellectual property is to the 21st century what the slave |
  `\                              trade was to the 16th.” —David Mertz |
_o__)                                                                  |
Ben Finney



More information about the Python-ideas mailing list