Re: Superclass initialization

2009-04-24 Thread Aahz
In article , Ole Streicher wrote: > >I am trying to initialize a class inherited from numpy.ndarray: > >from numpy import ndarray > >class da(ndarray): >def __init__(self, mydata): >ndarray.__init__(self, 0) >self.mydata = mydata > >When I now call the constructor of da: >da(r

Re: Superclass initialization

2009-04-24 Thread Arnaud Delobelle
On Apr 24, 3:46 pm, Ole Streicher wrote: > Arnaud Delobelle writes: > > numpy.ndarray has a __new__ method (and no __init__).  I guess this is > > the one you should override.  Try: > > What is the difference? > > best regards > > Ole Here's an explanation. http://www.python.org/download/re

Re: Superclass initialization

2009-04-24 Thread Ole Streicher
Arnaud Delobelle writes: > numpy.ndarray has a __new__ method (and no __init__). I guess this is > the one you should override. Try: What is the difference? best regards Ole -- http://mail.python.org/mailman/listinfo/python-list

Re: Superclass initialization

2009-04-24 Thread Ole Streicher
Steven D'Aprano writes: > Perhaps you should post the full trace back instead of just the final > line. No Problem, although I dont see the information increase there: In [318]: class da(ndarray): .: def __init__(self, mydata): .: ndarray.__init__(self, 0) .

Re: Superclass initialization

2009-04-24 Thread Arnaud Delobelle
On Apr 24, 3:04 pm, Ole Streicher wrote: > Hi again, > > I am trying to initialize a class inherited from numpy.ndarray: > > from numpy import ndarray > > class da(ndarray): >     def __init__(self, mydata): >         ndarray.__init__(self, 0) >         self.mydata = mydata > > When I now call the

Re: Superclass initialization

2009-04-24 Thread Steven D'Aprano
On Fri, 24 Apr 2009 16:04:00 +0200, Ole Streicher wrote: > I get the message: > > ValueError: sequence too large; must be smaller than 32 > > which I do not understand. This message is generated by the constructor > of ndarray, but the ndarray constructor (ndarray.__init__()) has only > "0" as a

Superclass initialization

2009-04-24 Thread Ole Streicher
Hi again, I am trying to initialize a class inherited from numpy.ndarray: from numpy import ndarray class da(ndarray): def __init__(self, mydata): ndarray.__init__(self, 0) self.mydata = mydata When I now call the constructor of da: da(range(100)) I get the message: ValueE