TypeError: 'kwarg' is an invalid keyword argument for this function

Rustom Mody rustompmody at gmail.com
Sun Oct 12 09:46:04 EDT 2014


Whats the problem??
Seems to work (python 2.7.8)

[Ive added a line so that that you can see]

class C:
   def __init__(self):
       pass

class C2(C):
    def __init__(self, *args, **kwargs):
        self.dic = kwargs
        pass
x = C2(kwarg='a')
y = C2(kwarg='a', kwarg2=8)


========================
>>> x.dic
{'kwarg': 'a'}
>>> y.dic
{'kwarg': 'a', 'kwarg2': 8}
>>> 



More information about the Python-list mailing list