On 2009-02-27 14:54, fredbasset1...@gmail.com wrote:
I'm writing a C extension for Python, is it possible to define
constants in the C code and have them visible from Python?

In your init<module> function, create Python objects from the constants and insert them into the module using PyModule_AddObject(). The initspam() function in this section does this (though not with #defined constants):

http://docs.python.org/extending/extending.html#providing-a-c-api-for-an-extension-module

--
Robert Kern

"I have come to believe that the whole world is an enigma, a harmless enigma
that is made terrible by our own mad attempt to interpret it as though it had
 an underlying truth."
  -- Umberto Eco

--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to