Last active
November 19, 2015 14:25
-
-
Save yinian1992/b353b0b44fa6893e8e7a to your computer and use it in GitHub Desktop.
The most god-stick-like code written in Python this year.
This file contains 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
# God-stick-like | |
from itertools import chain, repeat | |
from functools import partial, reduce | |
this_is_a_list = [1, 2, 3, 4, 5] | |
what_you_want = reduce(chain, map(partial(repeat, times=2), this_is_a_list)) | |
# Normal | |
this_is_a_list = [1, 2, 3, 4, 5] | |
what_you_want = [val for val in this_is_a_list for i in range(2)] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment