[Python-ideas] Another attempt at a sum() alternative: the concatenation protocol

Oscar Benjamin oscar.j.benjamin at gmail.com
Tue Jul 16 16:25:08 CEST 2013


On 16 July 2013 13:28, Joshua Landau <joshua at landau.ws> wrote:
> On 16 July 2013 11:21, Oscar Benjamin <oscar.j.benjamin at gmail.com> wrote:
>> On 16 July 2013 07:50, Nick Coghlan <ncoghlan at gmail.com> wrote:
>>
>> If people are using sum() to concatenate lists then this should be
>> taken not as evidence that a new solution needs to be found but as
>> evidence that chain is not sufficiently well-known. The obvious
>> solution to that is not to implement a new protocol but to make the
>> existing solution more well known i.e. move chain.from_iterable to
>> builtins and rename it (the obvious choice being concat).
>
> You could wait for PEP 448, which will let you use [*sublist for
> sublist in list_to_be_flattened].

Well that does look good. How exactly does it unroll? Does the *
translate as yield from but without the weird comprehension turning
into a generator function behaviour?


Oscar


More information about the Python-ideas mailing list