You are fundamentally correct about my confusion, though I'm trying to work
with tuples as the lowest level, which may not be relevant here.


-----Original Message-----
.

py> H = [[1, 2]]
py> J = [H[0]]
py> print H
[[1, 2]]
py> print J
[[1, 2]]
py> H[0][0] = 99
py> print H  # expected, and got, [[99, 2]]
[[99, 2]]
py> print J  # expected [[1, 2]]
[[99, 2]]

--------------

Using your example:

Py> Import copy
py> H = [[1, 2]]
py> J = [H[0]]
py> print H
[[1, 2]]
py> print J
[[1, 2]]
py> H[0][1] = copy.deepcopy(H[0][0])
py> print H  # expected, and got, [[1,1]]
[[1,1]]
py> print J  # expected [[1,2]]  
[[1, 1]]

How do I decouple these references?

_______________________________________________
Tutor maillist  -  [email protected]
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor

Reply via email to