Keyword calling gotcha ?

Darrell news at dorb.com
Wed May 26 17:49:30 EDT 1999


Yes I see the problem.
But I don't like it.
Keyword parms aren't as useful as I though they might be.
Using apply all over the place is not appealing.

--Darrell

Evan Simpson <evan at tokenexchange.com> wrote in message
news:AXX23.14$KR2.13445 at news.corridex.com...
> 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