Serhiy Storchaka <[email protected]> added the comment:
How common is the case of variable number of things to concatenate/union/merge?
>From my experience, in most ceases this looks like:
result = []
for ...:
# many complex statements
# may include continue and break
result.extend(items) # may be intermixed with result.append(item)
So concatenating purely lists from some sequence is very special case. And
there are several ways to perform it.
result = []
for items in seq:
result.extend(items)
# nothing wrong with this simple code, really
result = [x for items in seq for x in items]
# may be less effective for really long sublists,
# but looks simple
result = list(itertools.chain.from_iterable(items))
# if you are itertools addictive ;-)
----------
_______________________________________
Python tracker <[email protected]>
<https://bugs.python.org/issue33214>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe:
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com