RE: [Python-Dev] args attribute of Exception objects

2005-04-12 Thread Raymond Hettinger
[Sébastien de Menten] > 2) Could this be changed to .args more in line with: > a) first example: e.args = ('foo', "NameError: name 'foo' is not > defined") > b) second example: e.args = (4, 'foo', "'int' object has no attribute > 'foo'",) > the message of the string can even be retrieved

[Python-Dev] args attribute of Exception objects

2005-04-11 Thread Sébastien de Menten
Hi, When I need to make sense of a python exception, I often need to parse the string exception in order to retrieve the data. Example: try: print foo except NameError, e: print e.args symbol = e.args[0][17:-16] ==> ("NameError: name 'foo' is not defined", ) or try: (4).foo except Nam