Keyword passing to superclass written in C

Sven Erik Knop sknop at perforce.co.uk
Tue Nov 27 07:47:14 EST 2007


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)

I have tested Foo and Bar as Python classes and passing the keywords is 
not a problem. If I create Foo in C++ and call it directly, I can pass 
the keywords no bother.

But if I call Bar with keywords, it calls the C++ version of Foo with 
all arguments bunched together in "args" and not separated in args and 
keywords.

What am doing wrong?

This is Python 2.5.1 - on Ubuntu 7.0.4 if that makes any difference.

Thanks

Sven Erik




--------------------------------------------------------------------------------
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
--------------------------------------------------------------------------------



More information about the Python-list mailing list