B
black
Hi all~
i coded a class say named "A" which can receive arbitrary arguments and all works fine but problem came when i created another class "B" which inherited "A". it can not receive arguments as expected, ie it collected keywords arguments to nonekeywords arguments tuple and keep keywords dict empty. My destination is just to pass all keywords from A to B without any modification and same does nonekeywords. below is my code, I'd much appreciate if anyone could inspires me, thanx~
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)
a = A("a?", a_pro="a!")
b = B("b?", b_pro="b!")
you can see contents should be in kw of B was not in kw but args, how to fix it plz ?
Regards~
i coded a class say named "A" which can receive arbitrary arguments and all works fine but problem came when i created another class "B" which inherited "A". it can not receive arguments as expected, ie it collected keywords arguments to nonekeywords arguments tuple and keep keywords dict empty. My destination is just to pass all keywords from A to B without any modification and same does nonekeywords. below is my code, I'd much appreciate if anyone could inspires me, thanx~
class A:
def __init__(self, *args, **kw):
print args
print kw
class B(A):
def __init__(self, *args, **kw):
A.__init__(self, args, kw)
a = A("a?", a_pro="a!")
b = B("b?", b_pro="b!")
you can see contents should be in kw of B was not in kw but args, how to fix it plz ?
Regards~