Hi Alex,
Thanks for your reply. It was exactly what I was looking for. Two
additional questions
1) Is there anyway to find out which modules a variable belongs to
when I have only its name (and its not qualified with the complete
name like module.varname)
2) Is there anyway to find the type of the object in C using something
like a switch statement? I was looking for something like this
switch type(object) {
STRING: "This is a string object";
break;
INTEGER: "This is an integer object";
break;
BOOLEAN: "This is a boolean object";
.........
.........
}
I don't want to run all the C Py***_Check functions on the object.
Something like the switch statement above will lead to nice and clean
code.
Thanks again for your reply.
Regards,
-Manas
On Jul 15, 11:02 pm, al...@mac.com (Alex Martelli) wrote:
MD <man...@gmail.comwrote:
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