This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author serhiy.storchaka
Recipients Javier Dehesa, christian.heimes, eric.araujo, iamsav, josh.r, serhiy.storchaka
Date 2019-09-16.09:53:43
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1568627623.68.0.0713012424787.issue33214@roundup.psfhosted.org>
In-reply-to
Content
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 ;-)
History
Date User Action Args
2019-09-16 09:53:43serhiy.storchakasetrecipients: + serhiy.storchaka, christian.heimes, eric.araujo, josh.r, Javier Dehesa, iamsav
2019-09-16 09:53:43serhiy.storchakasetmessageid: <1568627623.68.0.0713012424787.issue33214@roundup.psfhosted.org>
2019-09-16 09:53:43serhiy.storchakalinkissue33214 messages
2019-09-16 09:53:43serhiy.storchakacreate