Catching exceptions from Python 2.4 to 3.x
cs at zip.com.au
Sat Nov 17 04:26:43 CET 2012
On 17Nov2012 03:12, Steven D'Aprano <steve+comp.lang.python at pearwood.info> wrote:
| Oh for the day I can drop support for Python 2.4 and 2.5...
| I have some code that needs to run in any version of Python from 2.4
| onwards. Yes, it must be a single code base.
| I wish to catch an exception and bind the exception to a name.
| In Python 2.6 onwards, I can do:
| except Exception as err:
| But in 2.4 and 2.5 "as err" gives me a SyntaxError, and I have to write:
| except Exception, err:
| Is there some other trick to grab the current exception from inside an
| except block?
Cameron Simpson <cs at zip.com.au>
Peeve: Going to our favorite breakfast place, only to find that they were
hit by a car...AND WE MISSED IT.
- Don Baldwin, <donb at netcom.com>
More information about the Python-list