[Python Wpg] Newbie question

Dave Gabrielson dave at gabrielson.ca
Fri Feb 24 16:59:32 EST 2006


This one can take some digging if you don't know about it.
I've been bit before, so I know about it:

import copy

a = copy.deepcopy(b)

will make new versions of everything contained by b for a.

--Dave.


On February 24, 2006 03:42 pm, Mike Pfaiffer wrote:
>  I'm redoing an old public domain Apple// BASIC (text) game in Python and
> submitting it as an article to the magazine in the .signature. I've been
> working on it for a couple of weeks an hour at a time (it's a simple game).
> It's a good way to learn the language. I've been following the tutorial and
> for the most part I can get by experimenting with the examples. I'll admit
> my technique leaves a lot to be desired (it's my first Python program -
> I'll clean it up when it's working). With expectations suitably lowered,
> here is my question...
>
>  I have a large list (2D array of single character strings) I want
> duplicated. Assignment (a = b) copies the pointers and not the values.
> Rather than copy the list item by item (which isn't out of the question),
> is there a simple way I haven't seen yet to make a separate copy of the
> list? I'd like to change one list but not the other.
>
>  FYI, I haven't quite got my head around the OO style of programming yet.
> Hopefully this year I'll try something which gives me the spark of insight
> I haven't got yet.
>
>     Later
>     Mike



More information about the Winnipeg mailing list