Superclass initialization

Ole Streicher ole-usenet-spam at gmx.net
Fri Apr 24 10:04:00 EDT 2009


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:

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 argument, and calling
"ndarray(0)" directly works perfect.

In the manual I found that the constructor of a superclass is not
called implicitely, so there should be no other call to
ndarray.__init__() the the one in my __init__ method.

I am now confused on where does the call to ndarray come from. How do
I correct that?

Best regards

Ole



More information about the Python-list mailing list