Modifying Python parms passed to C function?
Bernhard Herzog
herzog at online.de
Thu Aug 31 13:46:19 EDT 2000
"Richard Harvey" <tririch at connect.net> writes:
> Ugh, I was afraid you were going to say that! The reason I'm wanting to do
> this is that I have a collection of functions that users can call through a
> .DLL using C, or through Python using my extensions. I would greatly prefer
> if the interface and documentation would remain the same regardless of what
> tool the caller is using. What bothers me most is that Python does allow me
> to modify lists, tuples, or dictionaries using the SetItem functions, and I
> can essentially "pass back" the modified value; why do the PyInt_, PyFloat_,
> or PyStr_ classes not offer a "set" function from C?
Ints, floats and strings are immutable.
> Well, I guess if that is the best Python offers I'll probably only allow a
> small subset of my API to be available through Python, because the work it
> would take to code and document 500-600 functions with specific Python
> versions seems too costly.
You're passing pointers to the C-functions because you want to return
several values at once, right? The way that's usually done in Python is
by returning a tuple, so that the C code
int a;
float b;
myFunc(&a, &b);
becomes
a, b = myFunc(a, b)
in Python.
--
Bernhard Herzog | Sketch, a drawing program for Unix
herzog at online.de | http://sketch.sourceforge.net/
More information about the Python-list
mailing list