List Problem

Chris Angelico rosuav at gmail.com
Sun Sep 23 17:57:26 EDT 2012


On Mon, Sep 24, 2012 at 7:44 AM, jimbo1qaz <jimmyli1528 at gmail.com> wrote:
> On Sunday, September 23, 2012 2:31:48 PM UTC-7, jimbo1qaz wrote:
>> I have a nested list. Whenever I make a copy of the list, changes in one affect the other, even when I use list(orig) or even copy the sublists one by one. I have to manually copy each cell over for it to work.
>>
>> Link to broken code: http://jimbopy.pastebay.net/1090401
>
> No, actually that's the OK code. http://jimbopy.pastebay.net/1090494 is the broken one.

The first thing I'd change about that code is the whole thing of using
try/exec/except to suppress IndexError. Definitely not good code. I'm
not wholly certain, but I think you might run into weird issues with
negative OOBounds indices (since Python treats a negative list index
as counting from the far end).

This is nothing to do with your originally requested issue, which I
can't see the cause of in your script there. But when you assign a
list, you just get another reference to the same list.

ChrisA



More information about the Python-list mailing list