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


Groups > comp.lang.python > #82078

Re: Tuple of lists concatenation - function vs comprehension

From Terry Reedy <tjreedy@udel.edu>
Subject Re: Tuple of lists concatenation - function vs comprehension
Date 2014-12-07 17:21 -0500
References <001a01d0122f$86b95480$942bfd80$@gmail.com> <20141207151749.GB32773@FuzzyHorror> <001b01d01232$77700840$665018c0$@gmail.com>
Newsgroups comp.lang.python
Message-ID <mailman.16687.1417990918.18130.python-list@python.org> (permalink)

Show all headers | View raw


On 12/7/2014 10:28 AM, Ivan Evstegneev wrote:
> Hi Shiyao,
>
> Now I see, that it was kind of dumb question...
>
>>>>> x = ([1, 2], [3, 4], [5, 6])
>>>>> L = []
>>>> [L.extend(i) for i in x]
> [None, None, None]

Using a list comprehension for the expression side-effect, when you do 
not actually want the list produced by the comprehension, is considered 
bad style by many.  There is nothing wrong with explicit loops.

> BUT when I check L itself I'll see this one
>
>>>> L
> [1,2,3,5,6]


-- 
Terry Jan Reedy

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


Thread

Re: Tuple of lists concatenation  -  function vs comprehension Terry Reedy <tjreedy@udel.edu> - 2014-12-07 17:21 -0500
  Re: Tuple of lists concatenation  -  function vs comprehension Rustom Mody <rustompmody@gmail.com> - 2014-12-09 06:16 -0800

csiph-web