Peter Otten __peter__ at
Sat Aug 23 11:34:02 CEST 2003

Kris Caselden wrote:

> I've searched all the Python docs I could find, but I haven't seen any
> mention of referencing function arguments, such as you would with the
> & in c/c++. Is this possible in Python?

The analog of the Python way of handling args among the C-style languages is
Java. So, no, you are on mission impossible :-)

class Mutable:

v1 = Mutable() = "v1"
v2 = "v2" #strings are immutable

def fun(a1, a2): = "a1"
    a2 = "a2"
fun(v1, v2)

print # prints a1
print v2      # prints v2

As a workaround, you can do:

def fun2():
    a1 = Mutable() = "A1"
    return a1, "A2"

v1, v2 = fun2()

print # prints A1
print v2      # prints A2

See the tutorial ( for the
tricks you *can* do with function arguments


More information about the Python-list mailing list