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

Joshua Landau joshua at landau.ws
Tue Jul 16 14:28:41 CEST 2013


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].


More information about the Python-ideas mailing list