Setting value of Python variable in a Python C extension
manasd at gmail.com
Mon Oct 1 18:42:27 CEST 2007
Thanks for your reply. I am a newbie on Python so your help is
much appreciated. My program structure is basically like this .....
var1 = ""
rc = func1 (var1)
strcpy(v1, "Hello World");
So basically I want to modify value of "var1" in the function "func1"
defined in test.c. Is this possible?
On Oct 1, 11:26 am, Carsten Haese <cars... at uniqsys.com> wrote:
> On Mon, 2007-10-01 at 09:08 -0700, MD wrote:
> > Hi,
> > 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?
> Carsten Haesehttp://informixdb.sourceforge.net
More information about the Python-list