¡@

Home 

python Programming Glossary: chain.from_iterable

Power set and Cartesian Product of a set python

http://stackoverflow.com/questions/10342939/power-set-and-cartesian-product-of-a-set-python

1 2 3 1 2 3 1 2 1 3 2 3 1 2 3 s list iterable return chain.from_iterable combinations s r for r in range len s 1 For example test 1 2..

Interleaving Lists in Python [duplicate]

http://stackoverflow.com/questions/11125212/interleaving-lists-in-python

One option from itertools import chain izip list chain.from_iterable izip list_a list_b Edit As pointed out by sr2222 in the comments..

Double Iteration in List Comprehension

http://stackoverflow.com/questions/1198777/double-iteration-in-list-comprehension

excellent itertools.chain from itertools import chain list chain.from_iterable a list chain a # If you're using python 2.6 share improve..

what's a good way to combinate through a set?

http://stackoverflow.com/questions/1482308/whats-a-good-way-to-combinate-through-a-set

1 2 3 1 2 3 1 2 1 3 2 3 1 2 3 s list iterable return chain.from_iterable combinations s r for r in range len s 1 Output list powerset..

Flatten a nested list of variable sized sublists into a SciPy array

http://stackoverflow.com/questions/15366053/flatten-a-nested-list-of-variable-sized-sublists-into-a-scipy-array

best of 3 25.2 ms per loop In 50 timeit np.array list chain.from_iterable lst 1000 1000 loops best of 3 1.81 ms per loop In 52 timeit.. loops best of 3 1.81 ms per loop In 52 timeit np.fromiter chain.from_iterable lst 1000 dtype 'int' 1000 loops best of 3 1 ms per loop share..

Convert multi-dimensional list to a 1D list in Python

http://stackoverflow.com/questions/2961983/convert-multi-dimensional-list-to-a-1d-list-in-python

flatten listOfLists Flatten one level of nesting return chain.from_iterable listOfLists To flatten more deeply nested lists including irregularly..

Flattening a shallow list in Python

http://stackoverflow.com/questions/406121/flattening-a-shallow-list-in-python

probably better style to avoid operator magic by using chain.from_iterable like so chain itertools.chain.from_iterable 1 2 3 5 89 6 print.. magic by using chain.from_iterable like so chain itertools.chain.from_iterable 1 2 3 5 89 6 print list chain 1 2 3 5 89 6 python list comprehension.. with the temporary. Edit As J.F. Sebastian says itertools.chain.from_iterable avoids the unpacking and you should use that to avoid magic..

foggy on asterisk in python

http://stackoverflow.com/questions/5239856/foggy-on-asterisk-in-python

As Jochen Ritzel has pointed out in the comments chain.from_iterable is better suited for this operation as it assumes a single iterable..