how to pass keyword arguments to derived class~
JZ
jroznfgre at jngpugbjreQBGbet.cy
Thu Dec 25 10:41:50 EST 2003
On Thu, 25 Dec 2003 03:36:16 -0800 (PST), black <quiteblack at yahoo.com>
wrote:
>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 used Python 2.3.3. What is your version?
>>> class A:
def __init__(self, *args, **kw):
print args
print kw
print
>>> class B(A):
def __init(self, *args, **kw):
A.__init__(self,arg,kw)
>>> a = A("a?", apro="a!")
('a?',)
{'apro': 'a!'}
>>> b = B("b?", bpro="b!")
('b?',)
{'bpro': 'b!'}
--
JZ
More information about the Python-list
mailing list