how to pass by reference??

Greg Weeks weeks at vitus.scs.agilent.com
Mon Feb 4 14:42:21 EST 2002


Grant Edwards (grante at visi.com) wrote:
: Everything in Python is passed by reference.  Always.

True.  But it is equally true that:

    Nothing in Python is passed by reference.  Never.

"passed by reference" is sufficiently ambiguous to cover both statements.

Once upon a time, "passed by reference" meant that a procedure call

    f(x)

passed the address of the variable x.  Nowadays, it sometimes means merely
that the value of x is an address.

Being old, I don't like the new vocabulary.  I like to say this, for
example:

    In Python, all data are represented internally as addresses, and these
    are passed by value.

Others might say:

    In Python, all data are represented internally by blocks of memory, and
    it is the addresses of these that are passed (by value):

Or:

    In Python, all data are represented internally by blocks of memory, and
    these are passed by reference.

They all mean the same thing.


Greg



More information about the Python-list mailing list