Keyword calling gotcha ?
Evan Simpson
evan at tokenexchange.com
Wed May 26 15:29:26 EDT 1999
Replace "A.__init__(self, parms)" with "apply(A.__init__, (self,), parms)".
"A.__init__" is expecting one fixed parameter plus any number of keyword
parameters. You're calling it with two fixed parameters, one of which
happens to be a dict obtained from keyword parameters.
Darrell wrote in message ...
Am I missing something ?
>>> class A:
... def __init__(self, **parms):
... pass
...
>>> class B(A):
... def __init__(self, **parms):
... A.__init__(self,parms)
...
>>> A(a=1,b=2)
<__main__.A instance at 7f85a0>
>>>
>>> B(a=1,b=2)
Traceback (innermost last):
File "<stdin>", line 1, in ?
File "<stdin>", line 3, in __init__
TypeError: too many arguments; expected 1, got 2
>>>
--Darrell
More information about the Python-list
mailing list