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


Groups > comp.lang.python > #6300

Re: Puzzled by list-appending behavior

X-FeedAbuse http://nntpfeed.proxad.net/abuse.pl feeded by 88.191.16.109
Path csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!news.dougwise.org!nntpfeed.proxad.net!nospam.fr.eu.org!usenet-fr.net!de-l.enfer-du-nord.net!feeder2.enfer-du-nord.net!newsfeed.eweka.nl!eweka.nl!feeder3.eweka.nl!newsfeed.xs4all.nl!newsfeed6.news.xs4all.nl!xs4all!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.007
X-Spam-Evidence '*H*': 0.99; '*S*': 0.00; '(python': 0.05; 'append': 0.09; 'list)': 0.09; 'pm,': 0.10; 'wrote:': 0.14; 'angelico': 0.16; 'elsewhere,': 0.16; 'finney': 0.16; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'subject:behavior': 0.16; 'subject:list': 0.19; 'uncle': 0.19; 'header:In-Reply-To:1': 0.21; 'variable': 0.21; 'thu,': 0.22; 'joining': 0.23; 'received:209.85.210.174': 0.23; 'received:mail- iy0-f174.google.com': 0.23; '(or': 0.24; 'creating': 0.24; 'point,': 0.25; '(in': 0.26; 'message-id:@mail.gmail.com': 0.28; 'answered': 0.29; 'lists': 0.29; 'class': 0.29; 'confusion': 0.30; 'to:addr:python-list': 0.33; 'generally': 0.33; 'list': 0.33; 'list.': 0.33; 'chris': 0.34; 'actual': 0.36; 'lists,': 0.36; 'received:google.com': 0.37; 'something': 0.37; 'received:209.85': 0.37; 'playing': 0.37; 'two': 0.37; 'but': 0.38; 'question,': 0.38; 'subject:: ': 0.38; 'called': 0.39; 'received:209': 0.39; 'list,': 0.39; 'add': 0.39; 'to:addr:python.org': 0.39; 'following:': 0.40; 'plain': 0.40; '26,': 0.67; 'saving': 0.74; '3.1,': 0.84
DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:in-reply-to:references:date :message-id:subject:from:to:content-type; bh=GbJKqX3rIA5Q0JXF6T2lVG+9SysZSAqNK/yJ+6GzWV4=; b=Gv6ZdT1vZSTl22T8vW8Sz15YJ+pI1VMGEWTewfbwUv8txlPkWgeBrfjW4u650JXxZ6 6R9FwFSMQE+YeDJKY0X0rmau7N90rFkxiijcICSqNK/YO1MOk4xcMQeayD4sYbvDNfj4 mi+suYtYzQRItctlyN2lKtAHgA1HFxpP7ttSo=
DomainKey-Signature a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type; b=AvRmvBfrPQlpO3MNO5kap54mjI9FL62+Yr54+DVpsZ+vN6ffvyvLDkt0oYU0XMuEld CeRrSCw7dr9ySoYW3TlS+7zMVYlwtdIuSR9S5FeWU4DSRx7JFb9PqK3JIDZ0Qvfc/9WF fHNt0BkwSik+lFJvQvcOalOu+ju5rX//AgB/Q=
MIME-Version 1.0
In-Reply-To <16c21256-48df-416a-971f-de49ca4cc981@x6g2000yqj.googlegroups.com>
References <16c21256-48df-416a-971f-de49ca4cc981@x6g2000yqj.googlegroups.com>
Date Thu, 26 May 2011 17:20:53 +1000
Subject Re: Puzzled by list-appending behavior
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.12
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.2111.1306394456.9059.python-list@python.org> (permalink)
Lines 23
NNTP-Posting-Host 82.94.164.166
X-Trace 1306394456 news.xs4all.nl 49180 [::ffff:82.94.164.166]:60130
X-Complaints-To abuse@xs4all.nl
Xref x330-a1.tempe.blueboxinc.net comp.lang.python:6300

Show key headers only | View raw


On Thu, May 26, 2011 at 2:46 PM, Uncle Ben <bgreen@nycap.rr.com> wrote:
> In playing with lists of lists, I found the following:
>
> (In 3.1, but the same happens also in 2.7)
>
> list = [1,2,3]

Ben Finney has already answered the main question, but as a side
point, I would generally avoid creating a variable called 'list'.
That's the name of the type (Python 2) or class (Python 3) of all
lists, so it might result in confusion if you have an actual list with
that name.

If you want the behaviour of joining two lists (or adding something to
a list) and saving the result elsewhere, you can use the plain
addition:

a=[1,2,3]
b=a+[[4,5,6]]

Note that you have to add a list, and it will append the contents of that list.

Chris Angelico

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


Thread

Puzzled by list-appending behavior Uncle Ben <bgreen@nycap.rr.com> - 2011-05-25 21:46 -0700
  Re: Puzzled by list-appending behavior Ben Finney <ben+python@benfinney.id.au> - 2011-05-26 15:11 +1000
  Re: Puzzled by list-appending behavior Chris Rebert <clp2@rebertia.com> - 2011-05-25 22:17 -0700
  Re: Puzzled by list-appending behavior Chris Angelico <rosuav@gmail.com> - 2011-05-26 17:20 +1000
  Re: Puzzled by list-appending behavior Chris Angelico <rosuav@gmail.com> - 2011-05-26 17:23 +1000
  Re: Puzzled by list-appending behavior Uncle Ben <bgreen@nycap.rr.com> - 2011-05-26 00:33 -0700
  Re: Puzzled by list-appending behavior Chris Rebert <clp2@rebertia.com> - 2011-05-26 01:09 -0700
  Re: Puzzled by list-appending behavior MRAB <python@mrabarnett.plus.com> - 2011-05-26 16:58 +0100
    Re: Puzzled by list-appending behavior Tim Roberts <timr@probo.com> - 2011-05-26 23:34 -0700
      Re: Puzzled by list-appending behavior MRAB <python@mrabarnett.plus.com> - 2011-05-27 17:02 +0100
  Re: Puzzled by list-appending behavior Chris Angelico <rosuav@gmail.com> - 2011-05-27 02:04 +1000
  Re: Puzzled by list-appending behavior John Ladasky <ladasky@my-deja.com> - 2011-05-26 11:27 -0700
    Re: Puzzled by list-appending behavior Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2011-05-27 01:59 +0000
      Re: Puzzled by list-appending behavior Chris Angelico <rosuav@gmail.com> - 2011-05-27 13:24 +1000
        Re: Puzzled by list-appending behavior Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2011-05-27 03:52 +0000
          Re: Puzzled by list-appending behavior Chris Angelico <rosuav@gmail.com> - 2011-05-27 14:10 +1000
          RE: Puzzled by list-appending behavior "Prasad, Ramit" <ramit.prasad@jpmchase.com> - 2011-05-27 13:58 -0400
          Re: Puzzled by list-appending behavior Ethan Furman <ethan@stoneleaf.us> - 2011-05-27 11:56 -0700
  Re: Puzzled by list-appending behavior Terry Reedy <tjreedy@udel.edu> - 2011-05-26 14:44 -0400
  RE: Puzzled by list-appending behavior "Prasad, Ramit" <ramit.prasad@jpmchase.com> - 2011-05-26 15:34 -0400
  Re: Puzzled by list-appending behavior Terry Reedy <tjreedy@udel.edu> - 2011-05-26 17:36 -0400

csiph-web