[EMAIL PROTECTED] schrieb:
How can I make a "var" parm, where the called function can modify
the value of the parameter in the caller?

def f(x):
    x = x + 1

n = 1
f(n)
# n should now be 2

Chris showed one way, another is simply returning it. As python can return ad-hoc created tuples & unpack them, some C++-wrappers for example treat out/inout vars like this:


def foo(in, inout):
    return inout, out1, out2


x, y, z = foo(a, x)

Obviously you are responsible for properly assigning the returned inout to the right name again.

Diez
--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to