Tuple of lists concatenation - function vs comprehension
Terry Reedy
tjreedy at udel.edu
Sun Dec 7 17:21:37 EST 2014
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
More information about the Python-list
mailing list