Message328264
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. |
|
Date |
User |
Action |
Args |
2018-10-22 16:21:35 | josh.r | set | recipients:
+ josh.r, Vasantha Ganesh Kanniappan |
2018-10-22 16:21:35 | josh.r | set | messageid: <1540225295.16.0.788709270274.issue35043@psf.upfronthosting.co.za> |
2018-10-22 16:21:35 | josh.r | link | issue35043 messages |
2018-10-22 16:21:35 | josh.r | create | |
|