On Thu, Oct 4, 2012 at 7:21 AM, Dave Angel wrote:
>
> This is how eryksun knew that a shallow copy was good enough. And for a
> shallow copy, using the slice notation is perfect.
>
J42 = [H[:1]]
print J42[0]
> [(1, 2)]
print id(J42[0])
> 13964568
>
> (Note that my shallow copy is n
On 10/03/2012 11:52 PM, Ed Owens wrote:
> 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.
The tuples are an example of an immutable object. An immutable object
(which contains only immutable objects) may
On Wed, Oct 3, 2012 at 11:52 PM, Ed Owens wrote:
>
> py> H = [[1, 2]]
> py> J = [H[0]]
> py> H[0][1] = copy.deepcopy(H[0][0])
>
> How do I decouple these references?
You can use the slice H[0][:] to get a shallow copy of the H[0] list.
By "shallow copy" I mean you get a new list that contains the
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, [
On 04/10/12 11:46, Ed Owens wrote:
I'm just learning Python, so I apologize for a newby question. I'm trying
to work with lists of lists, the lowest level of which hold one or more
tuples. I've tried to condense what I've tried.
Hi Ed, and welcome!
The code is:
I'm afraid I can't make he
I'm just learning Python, so I apologize for a newby question. I'm trying
to work with lists of lists, the lowest level of which hold one or more
tuples. I've tried to condense what I've tried. The code is:
#! Python 2.7
import copy
list = []
for i in range(8):
list.append((i, i+1))
H = [[l