[Python-Dev] Use Python 3.0 syntax for except and raise?

Raymond Hettinger python at rcn.com
Sun Feb 17 20:42:09 CET 2008


[Christian Heimes]
> I like to run the 2to3 tool with raise and except fixers over the 2.6
> sources. The raise fixer changes "raise Exception, msg" to "raise
> Exception(msg)" and the except fixer replaces "except Exception, err" by
> "except Exception as err".

+1  The new syntax so much better that we should do this even if 3.0 did not exist.

There are some modules like Decimal that make a promise to run on earlier
versions of Python.  In those cases only the first change (backwards compatible)
should be made.  Our 5,000 line Decimal package will need to wait for 3.0 to
use the except/as form :-(

Raymond


More information about the Python-Dev mailing list