Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #29877

Re: List Problem

Path csiph.com!usenet.pasdenom.info!aioe.org!news.stack.nl!newsfeed.xs4all.nl!newsfeed6.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail
Return-Path <tyler@tysdomain.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.001
X-Spam-Evidence '*H*': 1.00; '*S*': 0.00; 'broken': 0.03; 'assign': 0.07; 'list?': 0.07; 'nested': 0.07; 'other,': 0.09; 'thread': 0.11; 'from:addr:tyler': 0.16; 'from:addr:tysdomain.com': 0.16; 'from:name:littlefield, tyler': 0.16; 'fully,': 0.16; 'message- id:@tysdomain.com': 0.16; 'received:69.164': 0.16; 'received:69.164.206': 0.16; 'received:69.164.206.65': 0.16; 'received:tds-solutions.net': 0.16; 'subject:Problem': 0.16; 'wrote:': 0.17; 'code.': 0.20; 'changes': 0.20; 'received:192.168.1.100': 0.22; 'work.': 0.23; "i've": 0.23; 'header:In-Reply-To:1': 0.25; 'header:User-Agent:1': 0.26; 'project:': 0.29; 'no,': 0.29; 'url:code': 0.29; 'subject:List': 0.33; 'to:addr:python-list': 0.33; 'code:': 0.33; 'pm,': 0.35; 'list.': 0.35; 'but': 0.36; 'why': 0.37; 'subject:: ': 0.38; 'to:addr:python.org': 0.39; 'received:192': 0.39; 'list,': 0.39; 'received:192.168': 0.40; 'link': 0.60; 'url:p': 0.63; 'light- weight': 0.84; 'care,': 0.91
X-Spam-Checker-Version SpamAssassin 3.3.1 (2010-03-16) on wuff
X-Spam-Level
X-Spam-Status No, score=-1.0 required=5.0 tests=ALL_TRUSTED autolearn=unavailable version=3.3.1
Date Sun, 23 Sep 2012 18:56:47 -0600
From "Littlefield, Tyler" <tyler@tysdomain.com>
User-Agent Mozilla/5.0 (Windows NT 6.1; WOW64; rv:15.0) Gecko/20120907 Thunderbird/15.0.1
MIME-Version 1.0
To python-list@python.org
Subject Re: List Problem
References <5126348a-8e87-493d-975c-d6273e59784c@googlegroups.com> <b6555e91-54ba-42fb-bd99-561cb971c2ce@googlegroups.com>
In-Reply-To <b6555e91-54ba-42fb-bd99-561cb971c2ce@googlegroups.com>
Content-Type text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding 7bit
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.15
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <http://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list/>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.1171.1348448230.27098.python-list@python.org> (permalink)
Lines 20
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1348448230 news.xs4all.nl 6851 [2001:888:2000:d::a6]:39274
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:29877

Show key headers only | View raw


On 9/23/2012 3:44 PM, jimbo1qaz 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.

I've not been following this thread fully, but why not just use 
x=list(y) to copy the list?
The issue is that when you assign i=[1,2,3] and then j = i, j is just a 
reference to i, which is why you change either and the other changes.

-- 
Take care,
Ty
http://tds-solutions.net
The aspen project: a barebones light-weight mud engine:
http://code.google.com/p/aspenmud
He that will not reason is a bigot; he that cannot reason is a fool; he that dares not reason is a slave.

Back to comp.lang.python | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

List Problem jimbo1qaz <jimmyli1528@gmail.com> - 2012-09-23 14:31 -0700
  Re: List Problem jimbo1qaz <jimmyli1528@gmail.com> - 2012-09-23 14:44 -0700
    Re: List Problem Chris Angelico <rosuav@gmail.com> - 2012-09-24 07:57 +1000
    Re: List Problem Dave Angel <d@davea.name> - 2012-09-23 18:03 -0400
    Re: List Problem Chris Angelico <rosuav@gmail.com> - 2012-09-24 08:27 +1000
      Re: List Problem Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2012-09-23 22:37 +0000
        Re: List Problem Chris Angelico <rosuav@gmail.com> - 2012-09-24 08:45 +1000
    Re: List Problem Chris Angelico <rosuav@gmail.com> - 2012-09-24 08:30 +1000
    Re: List Problem "Littlefield, Tyler" <tyler@tysdomain.com> - 2012-09-23 18:56 -0600
    Re: List Problem Chris Angelico <rosuav@gmail.com> - 2012-09-24 11:52 +1000
  Re: List Problem Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2012-09-23 22:07 +0000
  Re: List Problem jimbo1qaz <jimmyli1528@gmail.com> - 2012-09-23 15:44 -0700

csiph-web