On Wed, Jun 16, 2021 at 10:13:40PM -0700, Christopher Barker wrote:

> If, as suggested, flattening a list of lists is a common operation, a nice
> clean and efficient built in way to do it would be reasonable. Heck, you
> could make it a list method :-)

People have been talking about a flatten builtin or list method since 
Python 1.5 days. Perhaps it is time to do a PEP?

Here is one example implementation from eleven years ago:

https://code.activestate.com/recipes/577250-flatten-a-list/


Start designing the API for flatten and one quickly discovers that the 
problem isn't how to implement it, but the number of options that people 
may, or may not, want. What counts as an atomic type? Flatten all the 
way down or just one level? Return a list or an iterator? Inplace or a 
new list? Etc.



-- 
Steve
_______________________________________________
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/6JGIEO7EXKGDISIZJ6S4FTPJ5CIPVZMP/
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to