[C++-sig] [boost.python] Exposing contants at the module level
Markus Schöpflin
markus.schoepflin at comsoft.de
Thu Jul 7 17:50:26 CEST 2005
I need to do something similar like the errno module from python, namely
exponse a bunch of integer constants at the module level.
I had a look at how the errno module does the job, and basically, it does
it like this:
PyMODINIT_FUNC
initerrno(void)
{
PyObject *m, *d;
m = Py_InitModule3("errno", errno_methods, errno__doc__);
d = PyModule_GetDict(m);
...
repeat for each name and code:
PyObject *u = PyString_FromString(name);
PyObject *v = PyInt_FromLong((long) code);
PyDict_SetItem(d, u, v);
...
}
Is there some way in boost.python to get at the module dictionary, or at
the module object?
Or is there a better way to achieve this in boost.python?
TIA, Markus
More information about the Cplusplus-sig
mailing list