Keyword passing to superclass written in C
Sven Erik Knop
sknop at gmx.net
Tue Nov 27 11:12:46 EST 2007
Duh
of course. Not sure what I had done in Python/Python.
Now it works. Thanks a lot.
Sven Erik
Chris Mellon wrote:
> On Nov 27, 2007 6:47 AM, Sven Erik Knop <sknop at perforce.co.uk> wrote:
>
>> Hi
>>
>> I am getting slightly frustrated and wonder if you can help me.
>>
>> Consider a Python class Foo implemented in C++. I have declared an
>> initialization method like this
>>
>> static int
>> Foo_init(P4Adapter *self, PyObject *args, PyObject *kwds)
>> {
>>
>> }
>>
>> and I am subclassing Foo in Python, which works fine in principle,
>> except for passing keywords.
>>
>> Here is the subclass:
>>
>> class Bar(Foo):
>> def __init__(self, *args, **kwlist):
>> Foo.__init__(self, args, kwlist)
>>
>>
>
> This passes the args tuple and the kw dict as 2 regular arguments. You
> need to expand them in the second call if you want them to be passed
> as args and kwargs -
> Foo.__init__(self, *args, **kwargs)
>
--------------------------------------------------------------------------------
This email and any files transmitted with it are confidential and intended
solely for the use of the individual or entity to whom they are addressed. If
you have received this email in error please notify the system manager. Please
note that any views or opinions presented in this email are solely those of the
author and do not necessarily represent those of Perforce Software. Finally,
the recipient should check this email and any attachments for the presence of
viruses. Perforce Software accepts no liability for any damage caused by any
virus transmitted by this email.
Perforce Software UK Ltd is registered in England and Wales as company no.
3816019 at the following address: West Forest Gate, Wellington Road, Wokingham,
RG40 2AQ, UK
--------------------------------------------------------------------------------
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20071127/dc00c3d4/attachment.html>
More information about the Python-list
mailing list