try..except with empty exceptions

Terry Reedy tjreedy at udel.edu
Sat Apr 11 10:58:14 CEST 2015


On 4/10/2015 9:42 PM, Steven D'Aprano wrote:

> try:
>      spam()
> except:
>      # Implicitly an empty tuple.
>      pass

No, specified as equivalent to 'except BaseException:' (or 'except 
(BaseException,):', either of which are different from 'except ():'.
"An expression-less except clause, if present, must be last; it matches 
any exception."

-- 
Terry Jan Reedy




More information about the Python-list mailing list