[capi-sig] Constants in classes?

Remi K. remi.k2620 at gmail.com
Thu Dec 27 14:01:17 CET 2007


Thanks for the answer. I did what you told me after the module's
initialisation, it compiles well, however when I try to load my module with
python it throws the error:
TypeError: can't set attributes of built-in/extension type 'sfColor'
Any idea?

On Dec 27, 2007 12:53 PM, Gustavo Carneiro <gjcarneiro at gmail.com> wrote:

> On 27/12/2007, Remi K. <remi.k2620 at gmail.com> wrote:
>
> > Hello,
> > I am currently writing a python wrapper for the C++ SFML library (
> > http://sfml.sourceforge.net).
> > I know there is PyModule_AddIntConstant for adding constants to a
> > module,
> > but how can I add a constant to one of my module's classes? Is there an
> > easy
> > way to wrap enumerations?
> > Any help is appreciated :)
>
>
> Any type is an object:
>
> PyObject *enum_value = PyInt_FromLong(123);
> PyObject_SetAttrString((PyObject *) &FooBar_Type, enum_value);
> Py_DECREF(enum_value);
>
> --
> Gustavo J. A. M. Carneiro
> INESC Porto, Telecommunications and Multimedia Unit
> "The universe is always one step beyond logic." -- Frank Herbert


More information about the capi-sig mailing list