[Python-ideas] except expression

Stephen J. Turnbull stephen at xemacs.org
Sat Feb 15 09:36:44 CET 2014


Ram Rachum writes:

 > My favorite syntax so far is:

 >    x except Exception as e pass e.y

I think that this syntax is overengineering (regardless of the
keywords used).

That is, I think it's reasonable to have a syntax like

 >    x except Exception pass y

for the purpose of passing a specific default (especially because it's
a big step toward getting rid of the nuisance default parameters in
many APIs).  But the extended syntax here allows e.y to be the result
of an arbitrary calculation.  I think it's better to use the heavier
statement syntax in that case.  While I'm no authority on
"Pythonicity", somehow packing so much into the syntax

    x except Exception as e pass e.y

seems to the be kind of thing that the Zen refers to as "complicated".




More information about the Python-ideas mailing list