Accessing Python variables in an extension module
Alex Martelli
aleax at mac.com
Mon Jul 16 00:02:28 EDT 2007
MD <manasd at gmail.com> wrote:
> Hi,
>
> I would like to access "variables" defined in my Python program in
> a C module extension for Python. Is this possible? I looked at the
> Python C API reference but didn't find anything there that could help
> me.
If they're global variables of a certain module XYZ, your C code may
"import" XZY (or look it up in the C API equivalent of the sys.modules
dict) and get those variables as attributes of object XYZ. Is that what
you mean by ``variables defined in your Python program''...?
Alex
More information about the Python-list
mailing list