Last active
August 29, 2015 14:10
-
-
Save vrootic/2a5e12632d1187b8e908 to your computer and use it in GitHub Desktop.
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
| In [37]: a = iter(range(45)) | |
| In [38]: zip(*[a, a, a]) | |
| Out[38]: | |
| [(0, 1, 2), | |
| (3, 4, 5), | |
| (6, 7, 8), | |
| (9, 10, 11), | |
| (12, 13, 14), | |
| (15, 16, 17), | |
| (18, 19, 20), | |
| (21, 22, 23), | |
| (24, 25, 26), | |
| (27, 28, 29), | |
| (30, 31, 32), | |
| (33, 34, 35), | |
| (36, 37, 38), | |
| (39, 40, 41), | |
| (42, 43, 44)] | |
| In [39]: zip(*[iter(mylist), iter(mylist), iter(mylist)]) | |
| Out[39]: | |
| [(0, 0, 0), | |
| (1, 1, 1), | |
| (2, 2, 2), | |
| (3, 3, 3), | |
| (4, 4, 4), | |
| (5, 5, 5), | |
| (6, 6, 6), | |
| (7, 7, 7), | |
| (8, 8, 8), | |
| (9, 9, 9), | |
| (10, 10, 10), | |
| (11, 11, 11), | |
| (12, 12, 12), | |
| (13, 13, 13), | |
| (14, 14, 14), | |
| (15, 15, 15), | |
| (16, 16, 16), | |
| (17, 17, 17), | |
| (18, 18, 18), | |
| (19, 19, 19), | |
| (20, 20, 20), | |
| (21, 21, 21), | |
| (22, 22, 22), | |
| (23, 23, 23), | |
| (24, 24, 24), | |
| (25, 25, 25), | |
| (26, 26, 26), | |
| (27, 27, 27), | |
| (28, 28, 28), | |
| (29, 29, 29), | |
| (30, 30, 30), | |
| (31, 31, 31), | |
| (32, 32, 32), | |
| (33, 33, 33), | |
| (34, 34, 34), | |
| (35, 35, 35), | |
| (36, 36, 36), | |
| (37, 37, 37), | |
| (38, 38, 38), | |
| (39, 39, 39), | |
| (40, 40, 40), | |
| (41, 41, 41), | |
| (42, 42, 42), | |
| (43, 43, 43), | |
| (44, 44, 44)] | |
| # reference 的概念 | |
| # [iter(mylist)] * 5 是 5 個 iter(mylist) 的 ref,指向同一個 iter instance | |
| # [iter, iter, ...] 是 5 個 iter 的 reference 指向 5 個 iter instance |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment