how to pass by reference??

Chris Gonnerman chris.gonnerman at newcenturycomputers.net
Sun Feb 3 20:52:19 EST 2002


----- Original Message -----
From: "Spencer Doidge" <spencer at spencerdoidge.com>


> I really tried to RTM first this time, but I failed.
> Can someone give me a hint where in the doc html's it explains how to pass
> by reference?
> Specifically, I want to do the equivalent of this:

Briefly, you don't.  Or you do.  Mutable types (lists, dictionaries,
objects)
can be changed as you request, but immutable types (int, float, string)
can't.

Since Python supports returning multiple values (via tuples or lists) you
normally don't need to do this.

If you have a C function like this:

    int MyCFunction(char *buffer);

the Python equivalent would be called like this:

    intval, stringval = MyCFunctionWrapped()

or if the buffer is both input and output:

    intval, stringval = MyCFunctionWrapped(stringval)







More information about the Python-list mailing list