Re: args attribute of Exception objects

2005-04-13 Thread Sebastien de Menten
> Did I misunderstand the problem again? Hmmm, yes ! But I think I am not expressing clearly my concern :-) So my problem is that "default exception" are badly designed in their use of their args attribute. I know it is possible to subclass Exception as every object and add the attributes I want

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

Re: args attribute of Exception objects

2005-04-12 Thread Bengt Richter
On 12 Apr 2005 01:57:31 -0700, [EMAIL PROTECTED] (Sebastien de Menten) wrote: >Thank you guys for those good advices (and the very interesting >example of AST hacking). > >However, this was an example of use for Exception.args. It does not >alleviate my concerns about the fact that the args attrib

Re: args attribute of Exception objects

2005-04-12 Thread Sebastien de Menten
Thank you guys for those good advices (and the very interesting example of AST hacking). However, this was an example of use for Exception.args. It does not alleviate my concerns about the fact that the args attribute is poorly designed for standard Exceptions. It is as if the Exception design was

Re: args attribute of Exception objects

2005-04-11 Thread Bengt Richter
On 11 Apr 2005 03:31:23 -0700, [EMAIL PROTECTED] (Sebastien de Menten) wrote: >Jeremy Bowers <[EMAIL PROTECTED]> wrote in message news:<[EMAIL PROTECTED]>... >> On Fri, 08 Apr 2005 09:32:37 +, Sébastien de Menten wrote: >> >> > Hi, >> > >> > When I need to make sense of a python exception,

Re: args attribute of Exception objects

2005-04-11 Thread Steve Holden
Sebastien de Menten wrote: Jeremy Bowers <[EMAIL PROTECTED]> wrote in message news:<[EMAIL PROTECTED]>... On Fri, 08 Apr 2005 09:32:37 +, SÃÂbastien de Menten wrote: 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.

Re: args attribute of Exception objects

2005-04-11 Thread Sebastien de Menten
Jeremy Bowers <[EMAIL PROTECTED]> wrote in message news:<[EMAIL PROTECTED]>... > On Fri, 08 Apr 2005 09:32:37 +, SÃÂbastien de Menten wrote: > > > 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. > > W

Re: args attribute of Exception objects

2005-04-08 Thread Jeremy Bowers
On Fri, 08 Apr 2005 09:32:37 +, SÃbastien de Menten wrote: > 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. What exactly are you doing with this info? (Every time I started to do this, I found a better way

args attribute of Exception objects

2005-04-08 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