Embedding Python - Passing by Reference

Terry Reedy tjreedy at udel.edu
Thu Nov 29 19:11:25 EST 2007


<andy at britishideas.com> wrote in message 
news:6ef0cabb-5a41-4095-9654-c82cc39bdbe1 at e23g2000prf.googlegroups.com...
|I understand the parameters to Python functions are passed by reference:

Nope.  Python's name-object model is so far different from the named memory 
block model of Fortran/C/etc that terms invented for the latter are 
misleading when applied to Python.  Argument objects (or the contents 
thereof, or lists or dicts constructed therefrom) are bound to parameter 
names.  (See the archives for endless discussion of what to call this.)

| def foo(a):
|  a = a + 1
|
| Will change the value of a in the calling function.

Nope.  Try it with the interactive interpreter (or IDLE, etc, equivalent).
Only takes a minute to test whatever you meant by that.tjr


| 






More information about the Python-list mailing list