Expanding on CptPicard's post...
The id function gives the "identity" of an object, which is effectively the object's memory address, so you can use it to verify what CptPicard said. For example:
Code:
>>> p = [1.0,2.5,3.8]
>>> q = p
>>> id(p)
454904
>>> id(q)
454904
p and q both refer to the same object. Assigning a new value to p changes the object to which p refers (but does not change the object to which q refers):
Code:
>>> p = [-1.0,-2.0,-4.0]
>>> id(p)
8195168
>>> id(q)
454904
>>> q
[1.0, 2.5, 3.7999999999999998]
>>>
By the way, I agree with the gist of the other posters comments: learn how Python variables work; don't try to recreate C/C++.
Bookmarks