Subclassing array.array
Larry Bates
lbates at swamisoft.com
Fri Jun 18 09:31:06 EDT 2004
I think you meant to write:
class TestClass(array.array):
def __init__(self, array_type = "B"):
array.array(self, array_type)
Note that your "default" got gobbled upwhen
array.array was looking for first argument
to be self.
HTH,
Larry Bates
Syscon, Inc.
"Gus Tabares" <gustabares at verizon.net> wrote in message
news:c42b7031.0406180524.2c5d91fc at posting.google.com...
> Hello all,
>
> I'm trying to subclass array.array but having problems with a default
> parameter in the init constructor. Example:
>
> import array
>
> class TestClass(array.array):
> def __init__(self, array_type = "B"):
> array.array(array_type)
>
>
> >>> temp = TestClass()
> Traceback (most recent call last):
> File "<pyshell#1>", line 1, in ?
> temp = TestClass()
> TypeError: array() takes at least 1 argument (0 given)
>
> I think there is something that I'm not understanding here. Any help
> is appreciated.
>
>
> Thanks,
> Gus
More information about the Python-list
mailing list