As you know, if we simply do:
>>> a > 0 Traceback (most recent call last): File \"\", line 1, in a > 0 N
>>> import exceptions >>> try: ... a > 0 ... except exceptions.NameError, e: ... print e ... name 'a' is not defined >>>
You can parse exceptions string for '' to extract value.