r/shittyprogramming • u/CVh655FDBcZ1l • Apr 10 '19
One Line of Code™
https://gist.github.com/WorryingWonton/ce8a3a74b0298f0b734fe4dd0a883a63
101
Upvotes
r/shittyprogramming • u/CVh655FDBcZ1l • Apr 10 '19
View all comments
Show parent comment
1
u/the_pw_is_in_this_ID Apr 11 '19 edited Apr 11 '19
Maybe an advanced question for this thread, but: you went for collection (iterable?) syntax instead of generator syntax as the parameter to
sum. (Or whatever the syntaxes are called -[x for y in z]vs(x in y for z)). I always assumed thatsuminternally processes collection types identically to a generator? And I'm guessing that collection syntax doesn't allow deferred processing on the inner function - I.E[x for x in {infinite-primes}]never returns, while(x for x in {infinite-primes})just yields untilgetNext()(or something) is called?Is all this correct about Python? If so, is there really much of an advantage to
[]syntax vs()syntax? This all intrigues me.