Entry
Passing keyword arguments from one method to another
Jul 5th, 2000 10:00
Nathan Wallace, Hans Nowak, Snippet 141, Python FAQ
"""
Packages: faq;oop
"""
"""
4.76. How do I pass keyword arguments from one method to another?
Use apply. For example:
"""
class Account:
def __init__(self, **kw):
self.accountType = kw.get('accountType')
self.balance = kw.get('balance')
class CheckingAccount(Account):
def __init__(self, **kw):
kw['accountType'] = 'checking'
apply(Account.__init__, (self,), kw)
myAccount = CheckingAccount(balance=100.00)