Re: Hacking with __new__

2007-07-24 Thread Chris Mellon
On 7/24/07, Sandra-24 <[EMAIL PROTECTED]> wrote: > On Jul 24, 5:20 am, Bruno Desthuilliers [EMAIL PROTECTED]> wrote: > > IIRC, __new__ is supposed to return the newly created object - which you > > are not doing here. > > > > class Bar(Foo): > > def __new__(cls, a, b, c, *args): > >

Re: Hacking with __new__

2007-07-24 Thread Duncan Booth
Bruno Desthuilliers <[EMAIL PROTECTED]> wrote: > Duncan Booth a écrit : > (snip) >> I think what you want for Bar is something more along the lines: > > (snip) > >> class Bar(Foo): >> def __new__(cls, a, b, c, *args): >> print 'Bar.__new__', len(args) >> target = cls > You d

Re: Hacking with __new__

2007-07-24 Thread Sandra-24
On Jul 24, 5:20 am, Bruno Desthuilliers wrote: > IIRC, __new__ is supposed to return the newly created object - which you > are not doing here. > > class Bar(Foo): > def __new__(cls, a, b, c, *args): > print 'Bar.__new__', len(args) > if not args: > cls = Zoo >

Re: Hacking with __new__

2007-07-24 Thread Bruno Desthuilliers
Duncan Booth a écrit : (snip) > I think what you want for Bar is something more along the lines: (snip) > class Bar(Foo): > def __new__(cls, a, b, c, *args): > print 'Bar.__new__', len(args) > target = cls You don't use 'target' anywhere... > if not args: >

Re: Hacking with __new__

2007-07-24 Thread Duncan Booth
Sandra-24 <[EMAIL PROTECTED]> wrote: > So thinking myself clever with python I thought I could change > S3ResponseError to have a __new__ method which returns one of the 30 > new exceptions. That way none of the raise S3ResponseError code needs > changing. No problem. The trouble comes with those

Hacking with __new__

2007-07-23 Thread Sandra-24
Ok here's the problem, I'm modifying a 3rd party library (boto) to have more specific exceptions. I want to change S3ResponseError into about 30 more specific errors. Preferably I want to do this by changing as little code as possible. I also want the new exceptions to be a subclass of the old S3Re