pythong referencing/aliasing

Joshua Marshall joshway_without_spam at myway.com
Fri Apr 25 12:58:13 EDT 2003


Kevin Howe <khowe at perfnet.ca> wrote:
> How does Python handles variable references/aliases?

> Example:

> a = 1
> b = (REF)a
> b = 2
> print a

> In this case, since "b" is just a reference to "a", changes to "b"
> automatically change "a".

> Does python have this ability?

You're basically asking two questions, and both answers are "no".
There is no way to associate two variables the same address, and there
is no REF/address-of operator in Python.

As others have mentioned, you might be able to use lists to give you
the behavior you're looking for.




More information about the Python-list mailing list