B
black
Hi all~
I met problem when trying passing keyword arguments to derived class. my goal is to pass all keyword arguments to taht derived class as they did for superclass, but the result was not exactly what i want. below is my code:
class A:
def __init__(self, *args, **kw):
print args
print kw
print
class B(A):
def __init__(self, *args, **kw):
A.__init__(self, args, kw=kw)
a = A("a?", a_pro="a!")
b = B("b?", b_pro="b!")
here is the output:
('a?', )
{'a_pro':'a!'}
(('b?', ), ) # I want to get simply ('b?', ) here
{'kw':{'b_pro':'b!'}} # Here should also be ('b_pro':'b!')
any help ???
I met problem when trying passing keyword arguments to derived class. my goal is to pass all keyword arguments to taht derived class as they did for superclass, but the result was not exactly what i want. below is my code:
class A:
def __init__(self, *args, **kw):
print args
print kw
class B(A):
def __init__(self, *args, **kw):
A.__init__(self, args, kw=kw)
a = A("a?", a_pro="a!")
b = B("b?", b_pro="b!")
here is the output:
('a?', )
{'a_pro':'a!'}
(('b?', ), ) # I want to get simply ('b?', ) here
{'kw':{'b_pro':'b!'}} # Here should also be ('b_pro':'b!')
any help ???