Setting value of Python variable in a Python C extension
carsten at uniqsys.com
Mon Oct 1 18:26:15 CEST 2007
On Mon, 2007-10-01 at 09:08 -0700, MD wrote:
> I have a function developed in C that is being used as a Python
> extension. The function is being passed a variable from the Python
> program. Is it possible to change the value of this variable from
> within the C function?
That question is ill-defined because Python doesn't have variables.
Python has objects and names. "Change the value of this variable" can
either mean that you want to mutate an object that's passed by the
caller, which you can do as long as the object is mutable, or you want
to rebind a name in the caller's namespace, which you can't do.
Why do you think your function needs to have side-effects instead of
simply returning a return value?
More information about the Python-list