[Tutor] Re: slots - a more basic issue
Arthur Siegel
ajs@ix.netcom.com
Thu, 4 Jul 2002 14:02:05 -0400
Dman writes -
>Use a method signature such as :
> def __init__(self, x, y, color=None ):
>and you'll get :
>Traceback (most recent call last):
> File "<stdin>", line 1, in ?
>TypeError: __init__() got an unexpected keyword argument 'kolor'
Yeah, but I have lots of potential attributes, and lots
of inheritance relationships - which makes the method signature
unwieldy - just what **kw seems to be made for.
Looks like I'll end up with building a list of attributes and something
like:
for key in kws:
if key not in optlist:
print 'WARNING " %s" not a valid keyword for %s'
%(key,self.__class__.__name__)
Just found a bunch of typos in my demos doing this approach.
Art