<story><title>Comprehensions in Python the Jedi way</title><url>https://gist.github.com/bearfrieze/a746c6f12d8bada03589</url></story><parent_chain></parent_chain><comment><author>undershirt</author><text>I don&amp;#x27;t think the author realizes how appropriate the Jedi tone for this article is.  Comprehensions are the gateway drug to the dark side, away from imperative programming and toward languages that treat everything as expressions which snap together more freely.  It hints at an idea of making a `for` loop and an `if` statement return a value (see CoffeeScript).  But it also hints at the idea that useful idioms like the List Comprehension can merge&amp;#x2F;simplify existing constructs into a new, easier syntax-- and that there are languages that allow you to do this freely (see Lisp).&lt;p&gt;Python showed me the Force, but I&amp;#x27;m with the Dark Side now.</text></comment>
<story><title>Comprehensions in Python the Jedi way</title><url>https://gist.github.com/bearfrieze/a746c6f12d8bada03589</url></story><parent_chain></parent_chain><comment><author>a_bonobo</author><text>One interesting side-thing with list comprehensions in Python 2 vs. Python 3:&lt;p&gt;Python 2.7:&lt;p&gt;&amp;gt;list_of_numbers = [1,2,3]&lt;p&gt;&amp;gt;[x&amp;#x2F;2 for x in list_of_numbers]&lt;p&gt;&amp;gt;print(x)&lt;p&gt;3&lt;p&gt;Python 3:&lt;p&gt;&amp;gt;list_of_numbers = [1,2,3]&lt;p&gt;&amp;gt;[x&amp;#x2F;2 for x in list_of_numbers]&lt;p&gt;&amp;gt;print(x)&lt;p&gt;NameError: name &amp;#x27;x&amp;#x27; is not defined&lt;p&gt;They &amp;quot;leak&amp;quot; their variables in Python 2, if you&amp;#x27;re someone who reuses variables this can lead to an enormous headache!</text></comment>