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


Groups > comp.lang.python > #25027 > unrolled thread

Re: something go wrongly

Started byChris Rebert <clp2@rebertia.com>
First post2012-07-07 10:35 -0700
Last post2012-07-07 10:35 -0700
Articles 1 — 1 participant

Back to article view | Back to comp.lang.python

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  Re: something go wrongly Chris Rebert <clp2@rebertia.com> - 2012-07-07 10:35 -0700

#25027 — Re: something go wrongly

FromChris Rebert <clp2@rebertia.com>
Date2012-07-07 10:35 -0700
SubjectRe: something go wrongly
Message-ID<mailman.1897.1341682558.4697.python-list@python.org>
On Sat, Jul 7, 2012 at 10:23 AM, levi nie <levinie001@gmail.com> wrote:
> my code:
>
> aList=[1,2,3,4,5,6,7,8,9,10]
> xList=[1,2,3]
> print "now aList is",aList.extend(xList)
>
> output:
> now aList is None
>
> what i want is [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3]

See http://stackoverflow.com/a/1682601
list.extend(), list.append(), etc. operate in-place, mutating the
existing list object. Such methods return None to emphasize that they
do not create new lists.

Regards,
Chris

[toc] | [standalone]


Back to top | Article view | comp.lang.python


csiph-web