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


Groups > comp.lang.python > #29882

Re: List Problem

Path csiph.com!usenet.pasdenom.info!weretis.net!feeder1.news.weretis.net!feeder.erje.net!newsfeed.xs4all.nl!newsfeed5.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail
Return-Path <rosuav@gmail.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.004
X-Spam-Evidence '*H*': 0.99; '*S*': 0.00; 'assign': 0.07; 'list?': 0.07; 'sep': 0.09; 'thread': 0.11; '24,': 0.16; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'fully,': 0.16; 'subject:Problem': 0.16; 'mon,': 0.16; 'wrote:': 0.17; 'elements': 0.23; "i've": 0.23; 'header:In-Reply-To:1': 0.25; 'am,': 0.27; 'message-id:@mail.gmail.com': 0.27; 'lists': 0.31; 'subject:List': 0.33; 'problem': 0.33; 'to:addr:python- list': 0.33; 'received:google.com': 0.34; 'received:209.85': 0.35; 'but': 0.36; 'why': 0.37; 'received:209': 0.37; 'subject:: ': 0.38; 'to:addr:python.org': 0.39; 'list,': 0.39; 'header:Received:5': 0.40
DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type; bh=GU6xO/f0CpZdwaCHADXj8JP03f3ekVXTjSMi3KlJ1fo=; b=jQQYNiT/QVyJb/iRxJgz24FKBxW+fr5U4SZwIjcCx4SHDHFGCxlRv1NioKY5dtor1h F4OUnGsHzAhSQe+7WaIqHtdZzvS6hC0KeOgjJcqkCQUqsUuvl+U73swEDthJbBFGJP67 uYBHr3oqmvF5nXBhbe1CtjlF5Kj4FmlPbHjnsXprcnx51i1e6RcNG4q1ab974xf6mKXv rAEsvMrwBfbljtIQU5b0beGWA+eIdZgtGEgAH/kxSUCe5ozTUMjfOQ7PYGv9LqJWDmks 24EhJfUYGLhLdoKXl2ks0UPloNp3WkkDORRSfmRRgw60uMVmP2jefjLOjD06Knx2MOp3 QQuA==
MIME-Version 1.0
In-Reply-To <505FAFCF.6030502@tysdomain.com>
References <5126348a-8e87-493d-975c-d6273e59784c@googlegroups.com> <b6555e91-54ba-42fb-bd99-561cb971c2ce@googlegroups.com> <505FAFCF.6030502@tysdomain.com>
Date Mon, 24 Sep 2012 11:52:22 +1000
Subject Re: List Problem
From Chris Angelico <rosuav@gmail.com>
To python-list@python.org
Content-Type text/plain; charset=ISO-8859-1
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.1175.1348451545.27098.python-list@python.org> (permalink)
Lines 10
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1348451545 news.xs4all.nl 6848 [2001:888:2000:d::a6]:33914
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:29882

Show key headers only | View raw


On Mon, Sep 24, 2012 at 10:56 AM, Littlefield, Tyler
<tyler@tysdomain.com> wrote:
> 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.

The problem is with lists as elements of that list, so the key is deepcopy.

ChrisA

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