[C++-sig] Dynamic resolution of members and methods
jeremie.delaitre at technogerma.fr
Wed Dec 10 17:08:55 CET 2008
I have a C++ class that use a custom property system.
This property system allows me to add and remove properties at runtime.
I want to expose this class into Python.
The problem is: I want "a dynamic resolution" of the properties in Python.
# import my python extension
# get an instance of my C++ class
t = myModule.newInstance()
# access the property 'myProperty'
When I access the property, I want python to call a "callback" of mine
in the C++ extension) which will check if the requested property exists, and
if it does, return the corresponding value, otherwise generate an exception.
By looking at the python C API, I did not find a way to achieve this. It
that declaring a new type requires to have static arrays for members and
(yes, my property system allows me to declare new methods too, so I want
them with a similar system).
Any idea how I could resolve this (with Python3.0) ?
More information about the Cplusplus-sig