Last active
October 2, 2017 13:30
-
-
Save stevedoyle/52b945dbc80242d190c57ce685e6f63c to your computer and use it in GitHub Desktop.
itertools.chain
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
p = [(1,2,3), (2,4), (1,6)] | |
set(itertools.chain(*p)) | |
=> {1,2,3,4,5,6} | |
where: | |
*p expands the list elements into separate arguments | |
itertools.chain() chains all of the individual elements of each parameter (the tuple from p in this case) into a single iterable stream. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment