Just trolling along, flattening a list could be written as

functools.reduce(list.__iadd__, xs, [])

Right?

On Wed, Jun 16, 2021 at 22:53 David Mertz <me...@gnosis.cx> wrote:

> On Thu, Jun 17, 2021, 1:38 AM Chris Angelico
>
>> >>> list(chain.from_iterable(list_of_lists))
>>
>> > More-itertools has flatten():
>> https://more-itertools.readthedocs.io/en/stable/api.html#more_itertools.flatten.
>> That seems better than a method specific to lists.
>>
>> ... which is built on top of chain.from_iterable. :)
>>
>
> Oh, of course. And anyone can put it in their personal utility library
> too. I just meant it in the sense that the name might be more intuitive to
> beginners.
>
>> _______________________________________________
> Python-ideas mailing list -- python-ideas@python.org
> To unsubscribe send an email to python-ideas-le...@python.org
> https://mail.python.org/mailman3/lists/python-ideas.python.org/
> Message archived at
> https://mail.python.org/archives/list/python-ideas@python.org/message/2T53ADB3TVQJF2UENEXKB5G5ZWTQOQVW/
> Code of Conduct: http://python.org/psf/codeofconduct/
>
-- 
--Guido (mobile)
_______________________________________________
Python-ideas mailing list -- python-ideas@python.org
To unsubscribe send an email to python-ideas-le...@python.org
https://mail.python.org/mailman3/lists/python-ideas.python.org/
Message archived at 
https://mail.python.org/archives/list/python-ideas@python.org/message/QTXUMBUHFWBG572NPD6YUNT3FEUCIDEC/
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to