I have a class like this:
class FloatArray():
def __init__(self):
self.a = 1.5
def __new__( cls, value ):
data = (c_float * value)()
return data
array_1 = FloatArray(9)
print(array_1)
>>>> __main__.c_float_Array_9 object at 0x102228c80>
Now I want to make a FloatArray4 class inherits from FloatArray class and the value a can be called.
Here is the code for the second class.
class FloatArray4( FloatArray ):
def __init__(self):
super(FloatArray, self).__init__()
def printValue( self ):
print(self.a)
I have problems:
First, I have to call array_2 = FloatArray4(4)
which I don't want, I would like it to be called like this array_2 = FloatArray4()
, But I don't know how.
Second, when I tried to call array_2.printValue()
I got an error: AttributeError: 'c_float_Array_4' object has no attribute 'printValue'
Could any one please help?
Thanks.