Call parent class's function with *args and **kwds in python
我认为下面的代码应该打印
('b')
{'a':1}
1 2 3 4 5 6 7 8 9 10 11 12 | class Parent(object): def f(self, a, *args, **kwargs): print a print args print kwargs class Child(Parent): def f(self, a, *args, **kwargs): super(Child, self).f(a, *args, **kwargs) c = Child() c.f("a","b", {"a":1}) |
这是预期的输出。你似乎认为你的字典应该被当作关键字论点来对待。它不是,它也是像b一样的位置参数。
关键字参数
1 2 | f("a","b", akw=1): # your code |