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 josh.r
Recipients Vasantha Ganesh Kanniappan, josh.r
Date 2018-10-22.16:21:35
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1540225295.16.0.788709270274.issue35043@psf.upfronthosting.co.za>
In-reply-to
Content
Your example code doesn't behave the way you claim. my_list isn't changed, and `a` is a chain generator, not a list (without a further list wrapping).

In any event, there is no reason to involve reduce here. chain already handles varargs what you're trying to do without involving reduce at all:

a = list(itertools.chain(*my_list))

or if you prefer to avoid unnecessary unpacking:

a = list(itertools.chain.from_iterable(*my_list))

Either way, a will be [1, 2, 3, 4], and my_list will be unchanged, with no wasteful use of reduce.
History
Date User Action Args
2018-10-22 16:21:35josh.rsetrecipients: + josh.r, Vasantha Ganesh Kanniappan
2018-10-22 16:21:35josh.rsetmessageid: <1540225295.16.0.788709270274.issue35043@psf.upfronthosting.co.za>
2018-10-22 16:21:35josh.rlinkissue35043 messages
2018-10-22 16:21:35josh.rcreate