News for hackers. Stuff that matters.
Re:Python List Comprehensions Explained Visually by tsurantino on Wednesday December 02, 2015 @04:26PM (#10665951)
For those confused - the visual part is done in a GIF (i.e. http://treyhunner.com/images/list-comprehension-condition.gi...).

I think animating the transformation from a normal loop to a list comprehension is a great way to show how the syntax translates between the two forms. Very awesome and comprehensive post.

Re:Python List Comprehensions Explained Visually by hatmatrix on Wednesday December 02, 2015 @04:30PM (#10665985)
Maybe I'm an FP snob but it would have been nice to mention the analogy to set builder notation (though lists aren't sets - maybe multisets or bags) to indicate the existence of higher abstraction; not just syntactic sugar on the for-loop.

However, from a practical point of view I think it is great introduction for procedural programmers to begin using list comprehensions.

Re:Python List Comprehensions Explained Visually by dragonwriter on Wednesday December 02, 2015 @07:06PM (#10666835)
> though lists aren't sets - maybe multisets or bags

arrays/lists (like maps/hashes, though with a more narrow restriction on the indices) are (or at least are isomorphic to) sets of pairs of (index, element).

They carry information about order which does not exist in multisets/bags.

Re:Python List Comprehensions Explained Visually by msellout on Wednesday December 02, 2015 @06:26PM (#10666653)
collections.Counter was designed with multiset in mind.