On Fri, Feb 4, 2011 at 8:01 AM, brett.cannon <python-check...@python.org> wrote: > +Capturing the Currently Raised Exception > +---------------------------------------- > +One change between Python 2 and 3 that will require changing how you code is > +accessing the currently raised exception. In Python 2 the syntax to access > the > +current exception is:: > + > + try: > + raise Exception() > + except Exception, exc: > + # Current exception is 'exc' > + pass > + > +This syntax changed in Python 3 to:: > + > + try: > + raise Exception() > + except Exception as exc: > + # Current exception is 'exc' > + pass
Note that you can write it the Python 3 way in 2.6+ as well (this was new syntax, so there weren't any backwards compatibility issues with adding it). You only need to do the sys.exc_info dance if you need to support 2.5 or earlier. Other notes: - explicit relative imports work in 2.6+ without needing a future import - absolute imports are the default in 2.7 Cheers, Nick. -- Nick Coghlan | ncogh...@gmail.com | Brisbane, Australia _______________________________________________ Python-Dev mailing list Python-Dev@python.org http://mail.python.org/mailman/listinfo/python-dev Unsubscribe: http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com