C-API: Get scope in function

moerchendiser2k3 googler.1.webmaster at spamgourmet.com
Sun Jan 17 08:23:03 EST 2010


Hi,

I have a small problem how to get the scope from a C-API function.
Check out this code snippet:

[code]
variable = 3

def test():
    print variable #output: 3
    print globals() # ... 'variable': 3, ...

test()
[/code


In my case I know there is a variable in the scope where this function
is called from, but I dont know how to get it.
Check out:

[code]
PyObject *MyFunction_Test(PyObject* self, PyObject *args, PyObject
*keywords)
{
     ... ?
}
[/code]

Is it possible to get the dictionary of the scope where this function
is called from?


Thanks a lot!!

Bye, googler



More information about the Python-list mailing list