[C++-sig] properties in python class that extend c++ base

Neal Becker ndbecker2 at gmail.com
Tue Oct 30 19:01:39 CET 2007


English, Mark wrote:

>> -----Original Message-----
>> From: c++-sig-bounces at python.org
>> [mailto:c++-sig-bounces at python.org] On Behalf Of Neal Becker
>> Sent: 30 October 2007 11:54
>> To: c++-sig at python.org
>> Subject: [C++-sig] properties in python class that extend c++ base
>> 
>> I have a c++ class with a property:
>> class_<mod_t> ("mod"...
>>     .add_property ("SPS", &mod_t::SPS)
>> 
>> If I subclass this class in python:
>> 
>> class X (mod):
>> 
>> Then when python code attempts to access the property in the
>> derived class, it fails:
>> Boost.Python.ArgumentError: Python argument types in
>>     None.None(pi4_modulator)
>> did not match C++ signature:
>>     None(modulator<non_offset_modbase, double> {lvalue})
>> 
>> Is there a solution to this?
> If you overrode __init__ in the subclass, did you remember to call the
> Base class's __init__ ?
> What's the held type of the class_ ?

Thanks guys.  Yup, I had forgotten to call Base class __init__.




More information about the Cplusplus-sig mailing list