Passing variable-length keyworded arguments list to base class constructor?

Jerome Quelin jerome.quelin at insalien.org
Fri Jun 30 08:14:41 EDT 2000


"Alex Martelli" <alex at magenta.com> wrote:
>> I was wondering how to pass variable-length keyworded arguments list
>> to my base-class constructor? Look at the example code below:
>Doesn't apply work for __init__ just as for any other function?
Sure it works for __init__ too, I've already tried this approch, but it doesn't
work either. In fact, I'm asking the question for __init__ because I run into
this problem when calling constructors, but the question is the same for every
inherited and overloaded method.

When using the *args syntax, I get an error when calling my constructor because
I'm using keywords arguments.

When using the **args syntax, python fetches all keyworded arguments in _one_
dictionnary in my constructor, and I want to keep the arguments in multiple
key/value pairs (and not flattened in one dictionnary) since the parent
constructor is waiting for keyworded arguments too.
If I use the **args syntax and then call the base constructor with:
Parent.__init__(self, args)
I got an error since it doesn't wait for a dictionnary as an argument (and args
is a dictionnary in this case) but for key=value arguments, with key and value
taken from the args dictionnary.

Any idea?
Jerome
--
jerome.quelin at insalien.org



More information about the Python-list mailing list