[Python-Dev] Py3k: Except clause syntax (original) (raw)

skip at pobox.com skip at pobox.com
Fri Mar 17 04:05:33 CET 2006


Greg> except <type> as <value>:

Baptiste> except <type> with <value>:

Can I catch multiple exceptions with a single value in this case? Today, I write:

try:
    foo()
except (TypeError, KeyError), msg:
    print msg

Either of the above seem like they'd require me to repeat the value, e.g:

try:
    foo()
except TypeError with msg, KeyError with msg:
    print msg

Not very Pythonic methinks.

Skip



More information about the Python-Dev mailing list