Passing variable-length keyworded arguments list to base class constructor?
Gordon McMillan
gmcm at hypernet.com
Fri Jun 30 20:23:57 EDT 2000
More information about the Python-list mailing list
Fri Jun 30 20:23:57 EDT 2000
- Previous message (by thread): Passing variable-length keyworded arguments list to base class constructor?
- Next message (by thread): Class design: accessing "private" members
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Jerome Quelin wrote: >gmcm at hypernet.com (Gordon McMillan) wrote: >>>But how to pass this dictionnary to the parent class constructor? >>class F(Frame): >> def __init__(self, *args, **kwargs): >> apply(Frame.__init__, (self,)+args, kwargs) >>Generally you have to muck with the kwargs dict before passing it to the >>base class __init__. >That is exactly what I want to know: what this mucking consists of? Depends on what args the base class expects. If the base class expects **kwargs, then you can have anything in there. But if the base class were defined: class Frame: def __init__(self, x=0, y=0): .... And the kwargs you pass it has {'snoo':33,...}, it's going to barf. But maybe you've been playing with the interpreter, and have discovered all this by now... - Gordon
- Previous message (by thread): Passing variable-length keyworded arguments list to base class constructor?
- Next message (by thread): Class design: accessing "private" members
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Python-list mailing list