<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/'><id>tag:blogger.com,1999:blog-6237161444180571452.post2008531335235183215..comments</id><updated>2010-11-07T01:04:29.985-08:00</updated><category term='plone'/><category term='reviews'/><category term='opensuse'/><category term='python'/><category term='mandriva'/><category term='sles'/><category term='zope'/><category term='archlinux'/><category term='guides'/><category term='fedora'/><category term='django'/><category term='general'/><category term='suse'/><title type='text'>Comments on Lowkster - Pythonly yours: List comprehension ruby vs python</title><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://blog.lowkster.com/feeds/2008531335235183215/comments/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6237161444180571452/2008531335235183215/comments/default'/><link rel='alternate' type='text/html' href='http://blog.lowkster.com/2010/11/list-comprehension-ruby-vs-python.html'/><author><name>lowks</name><uri>http://www.blogger.com/profile/02110530883983060094</uri><email>noreply@blogger.com</email><gd:image xmlns:gd='http://schemas.google.com/g/2005' rel='http://schemas.google.com/g/2005#thumbnail' width='26' height='32' src='http://4.bp.blogspot.com/_eVgoKogosHI/Syw7w1iCCNI/AAAAAAAAAF4/XMzRuAVJvRE/S220/lowkster.jpeg'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>15</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>25</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-6237161444180571452.post-3625780380077074321</id><published>2010-11-07T01:04:29.985-08:00</published><updated>2010-11-07T01:04:29.985-08:00</updated><title type='text'>Hi,


#the numpy way
evens = numbers[(numbers%2) =...</title><content type='html'>Hi,&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;#the numpy way&lt;br /&gt;evens = numbers[(numbers%2) == 0]&lt;br /&gt;&lt;br /&gt;Numpy can use index results to index into arrays.  So the (numbers % 2) == 0 part returns an array of True, False... etc.  The part inside [] is just an index after all :)&lt;br /&gt;&lt;br /&gt;# How about the Using more than one line in python to make it readable way ;)&lt;br /&gt;&lt;br /&gt;def is_even(b):&lt;br /&gt;    return b % 2 == 0&lt;br /&gt;&lt;br /&gt;even_numbers = [x*3 for x in [1,2,3,4,5] if is_even(x)]&lt;br /&gt;&lt;br /&gt;I think the python one is better for reading because if you know how to use for loops you can read list comprehensions.&lt;br /&gt;&lt;br /&gt;I do like the method chaining methods way of ruby though.  You can just keep adding to the filtering of results as you go.  I wish the python API was designed to allow chaining.</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6237161444180571452/2008531335235183215/comments/default/3625780380077074321'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6237161444180571452/2008531335235183215/comments/default/3625780380077074321'/><link rel='alternate' type='text/html' href='http://blog.lowkster.com/2010/11/list-comprehension-ruby-vs-python.html?showComment=1289120669985#c3625780380077074321' title=''/><author><name>illume</name><uri>http://www.blogger.com/profile/17762358075557755436</uri><email>noreply@blogger.com</email><gd:image xmlns:gd='http://schemas.google.com/g/2005' rel='http://schemas.google.com/g/2005#thumbnail' width='27' height='32' src='http://4.bp.blogspot.com/_eJJgehXCsQ4/TE10SeUr1qI/AAAAAAAAAIE/SzR-BlSvV1I/s1600-R/rd.png'/></author><thr:in-reply-to xmlns:thr='http://purl.org/syndication/thread/1.0' href='http://blog.lowkster.com/2010/11/list-comprehension-ruby-vs-python.html' ref='tag:blogger.com,1999:blog-6237161444180571452.post-2008531335235183215' source='http://www.blogger.com/feeds/6237161444180571452/posts/default/2008531335235183215' type='text/html'/><gd:extendedProperty xmlns:gd='http://schemas.google.com/g/2005' name='blogger.itemClass' value='pid-118503189'/></entry><entry><id>tag:blogger.com,1999:blog-6237161444180571452.post-6475885077083107370</id><published>2010-11-05T07:19:46.084-07:00</published><updated>2010-11-05T07:19:46.084-07:00</updated><title type='text'>I suppose I&amp;#39;m exposed as an old hacker for poi...</title><content type='html'>I suppose I&amp;#39;m exposed as an old hacker for pointing out that for odd numbers x&amp;amp;1 is true?&lt;br /&gt;&lt;br /&gt;[ x*3 for x in [1,2,3,4,5] if x&amp;amp;1 ]</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6237161444180571452/2008531335235183215/comments/default/6475885077083107370'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6237161444180571452/2008531335235183215/comments/default/6475885077083107370'/><link rel='alternate' type='text/html' href='http://blog.lowkster.com/2010/11/list-comprehension-ruby-vs-python.html?showComment=1288966786084#c6475885077083107370' title=''/><author><name>paulC</name><uri>http://www.blogger.com/profile/17574951208378597078</uri><email>noreply@blogger.com</email><gd:image xmlns:gd='http://schemas.google.com/g/2005' rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:in-reply-to xmlns:thr='http://purl.org/syndication/thread/1.0' href='http://blog.lowkster.com/2010/11/list-comprehension-ruby-vs-python.html' ref='tag:blogger.com,1999:blog-6237161444180571452.post-2008531335235183215' source='http://www.blogger.com/feeds/6237161444180571452/posts/default/2008531335235183215' type='text/html'/><gd:extendedProperty xmlns:gd='http://schemas.google.com/g/2005' name='blogger.itemClass' value='pid-1753860210'/></entry><entry><id>tag:blogger.com,1999:blog-6237161444180571452.post-321188796312259171</id><published>2010-11-04T19:13:30.495-07:00</published><updated>2010-11-04T19:13:30.495-07:00</updated><title type='text'>I also find the python form easier to read.  It ma...</title><content type='html'>I also find the python form easier to read.  It may be my background in math that does it.  It&amp;#39;s very well defined and concise.  {y | y=x^3 for x element of {1,2,3,4,5} and x mod 2 = 0}</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6237161444180571452/2008531335235183215/comments/default/321188796312259171'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6237161444180571452/2008531335235183215/comments/default/321188796312259171'/><link rel='alternate' type='text/html' href='http://blog.lowkster.com/2010/11/list-comprehension-ruby-vs-python.html?showComment=1288923210495#c321188796312259171' title=''/><author><name>CLM</name><uri>http://www.blogger.com/profile/00178410362737446235</uri><email>noreply@blogger.com</email><gd:image xmlns:gd='http://schemas.google.com/g/2005' rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:in-reply-to xmlns:thr='http://purl.org/syndication/thread/1.0' href='http://blog.lowkster.com/2010/11/list-comprehension-ruby-vs-python.html' ref='tag:blogger.com,1999:blog-6237161444180571452.post-2008531335235183215' source='http://www.blogger.com/feeds/6237161444180571452/posts/default/2008531335235183215' type='text/html'/><gd:extendedProperty xmlns:gd='http://schemas.google.com/g/2005' name='blogger.itemClass' value='pid-2088450372'/></entry><entry><id>tag:blogger.com,1999:blog-6237161444180571452.post-8206098562156299736</id><published>2010-11-04T13:30:12.393-07:00</published><updated>2010-11-04T13:30:12.393-07:00</updated><title type='text'>I think the issue is in the mental model rather th...</title><content type='html'>I think the issue is in the mental model rather than how nice one looks over the other.&lt;br /&gt;&lt;br /&gt;The Ruby one is more logical in a step by step sense. You have your list, you select some items, you then multiply them. You can break it up into pieces. This is a big deal for many people&amp;#39;s mental models.&lt;br /&gt;&lt;br /&gt;The Python one is harder to &amp;quot;parse&amp;quot; unless you&amp;#39;re used to the style but is more elegant in a mathematical and syntactical sense. It&amp;#39;s a more complete singular identity.&lt;br /&gt;&lt;br /&gt;I&amp;#39;m a Rubyist but I appreciate Python&amp;#39;s list comprehensions (though Haskell&amp;#39;s approach is even nicer). I&amp;#39;m not convinced they would work well in Ruby, though, since they don&amp;#39;t fit into the Lego-like &amp;quot;blocks of code&amp;quot; model that Ruby is very consistent with. Python can enjoy more left-field syntax because it&amp;#39;s a less consistent language in terms of syntax already.</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6237161444180571452/2008531335235183215/comments/default/8206098562156299736'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6237161444180571452/2008531335235183215/comments/default/8206098562156299736'/><link rel='alternate' type='text/html' href='http://blog.lowkster.com/2010/11/list-comprehension-ruby-vs-python.html?showComment=1288902612393#c8206098562156299736' title=''/><author><name>Peter Cooper</name><uri>http://www.blogger.com/profile/15128608987278611416</uri><email>noreply@blogger.com</email><gd:image xmlns:gd='http://schemas.google.com/g/2005' rel='http://schemas.google.com/g/2005#thumbnail' width='28' height='32' src='http://bp1.blogger.com/_oF9HaQciATY/R91z03EHJ7I/AAAAAAAAAAM/E4MNKXGn5gQ/S220/peter-small-square.jpg'/></author><thr:in-reply-to xmlns:thr='http://purl.org/syndication/thread/1.0' href='http://blog.lowkster.com/2010/11/list-comprehension-ruby-vs-python.html' ref='tag:blogger.com,1999:blog-6237161444180571452.post-2008531335235183215' source='http://www.blogger.com/feeds/6237161444180571452/posts/default/2008531335235183215' type='text/html'/><gd:extendedProperty xmlns:gd='http://schemas.google.com/g/2005' name='blogger.itemClass' value='pid-1215233684'/></entry><entry><id>tag:blogger.com,1999:blog-6237161444180571452.post-7470214363427760897</id><published>2010-11-04T08:25:01.119-07:00</published><updated>2010-11-04T08:25:01.119-07:00</updated><title type='text'>the ruby code is incorrect

The map function passe...</title><content type='html'>the ruby code is incorrect&lt;br /&gt;&lt;br /&gt;The map function passed a block {|x| x*3}&lt;br /&gt;&lt;br /&gt;So it should be:&lt;br /&gt;[1,2,3,4,5].select(&amp;amp;:even?).map{|x| x*3}&lt;br /&gt;&lt;br /&gt;I guess this makes it more difficult to read.&lt;br /&gt;&lt;br /&gt;Could also do it this way if u dont like symbols:&lt;br /&gt;&lt;br /&gt;[1,2,3,4,5].select{|x| x if x%2 == 0}.map{|x| x*3</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6237161444180571452/2008531335235183215/comments/default/7470214363427760897'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6237161444180571452/2008531335235183215/comments/default/7470214363427760897'/><link rel='alternate' type='text/html' href='http://blog.lowkster.com/2010/11/list-comprehension-ruby-vs-python.html?showComment=1288884301119#c7470214363427760897' title=''/><author><name>MoMo</name><uri>http://www.blogger.com/profile/13761406050571357680</uri><email>noreply@blogger.com</email><gd:image xmlns:gd='http://schemas.google.com/g/2005' rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:in-reply-to xmlns:thr='http://purl.org/syndication/thread/1.0' href='http://blog.lowkster.com/2010/11/list-comprehension-ruby-vs-python.html' ref='tag:blogger.com,1999:blog-6237161444180571452.post-2008531335235183215' source='http://www.blogger.com/feeds/6237161444180571452/posts/default/2008531335235183215' type='text/html'/><gd:extendedProperty xmlns:gd='http://schemas.google.com/g/2005' name='blogger.itemClass' value='pid-1567090056'/></entry><entry><id>tag:blogger.com,1999:blog-6237161444180571452.post-6574685574966411235</id><published>2010-11-04T05:20:56.541-07:00</published><updated>2010-11-04T05:20:56.541-07:00</updated><title type='text'>Er, sorry about the formatting. No way to make tha...</title><content type='html'>Er, sorry about the formatting. No way to make that proper Python, I guess.</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6237161444180571452/2008531335235183215/comments/default/6574685574966411235'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6237161444180571452/2008531335235183215/comments/default/6574685574966411235'/><link rel='alternate' type='text/html' href='http://blog.lowkster.com/2010/11/list-comprehension-ruby-vs-python.html?showComment=1288873256541#c6574685574966411235' title=''/><author><name>Jeremy</name><uri>http://www.blogger.com/profile/03810174490250845739</uri><email>noreply@blogger.com</email><gd:image xmlns:gd='http://schemas.google.com/g/2005' rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:in-reply-to xmlns:thr='http://purl.org/syndication/thread/1.0' href='http://blog.lowkster.com/2010/11/list-comprehension-ruby-vs-python.html' ref='tag:blogger.com,1999:blog-6237161444180571452.post-2008531335235183215' source='http://www.blogger.com/feeds/6237161444180571452/posts/default/2008531335235183215' type='text/html'/><gd:extendedProperty xmlns:gd='http://schemas.google.com/g/2005' name='blogger.itemClass' value='pid-550353610'/></entry><entry><id>tag:blogger.com,1999:blog-6237161444180571452.post-2913488004027601944</id><published>2010-11-04T05:20:04.183-07:00</published><updated>2010-11-04T05:20:04.183-07:00</updated><title type='text'>I&amp;#39;m surprised how many people claim they never...</title><content type='html'>I&amp;#39;m surprised how many people claim they never need to check for even/oddness. It&amp;#39;s a pretty common task in web development, for example.&lt;br /&gt;&lt;br /&gt;As for LCs, one reason I prefer the Python way is that the expression can be read like a for loop:&lt;br /&gt;&lt;br /&gt;newlist = []&lt;br /&gt;for x in [1, 2, 3, 4, 5]:&lt;br /&gt;    if x % 2 ==0:&lt;br /&gt;        newlist.append(x)&lt;br /&gt;&lt;br /&gt;The right-hand side of the LC (&amp;quot;for x in ...&amp;quot;) translates perfectly into how you&amp;#39;d do the task in a regular loop.</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6237161444180571452/2008531335235183215/comments/default/2913488004027601944'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6237161444180571452/2008531335235183215/comments/default/2913488004027601944'/><link rel='alternate' type='text/html' href='http://blog.lowkster.com/2010/11/list-comprehension-ruby-vs-python.html?showComment=1288873204183#c2913488004027601944' title=''/><author><name>Jeremy</name><uri>http://www.blogger.com/profile/03810174490250845739</uri><email>noreply@blogger.com</email><gd:image xmlns:gd='http://schemas.google.com/g/2005' rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:in-reply-to xmlns:thr='http://purl.org/syndication/thread/1.0' href='http://blog.lowkster.com/2010/11/list-comprehension-ruby-vs-python.html' ref='tag:blogger.com,1999:blog-6237161444180571452.post-2008531335235183215' source='http://www.blogger.com/feeds/6237161444180571452/posts/default/2008531335235183215' type='text/html'/><gd:extendedProperty xmlns:gd='http://schemas.google.com/g/2005' name='blogger.itemClass' value='pid-550353610'/></entry><entry><id>tag:blogger.com,1999:blog-6237161444180571452.post-6850561369966785841</id><published>2010-11-04T05:18:11.925-07:00</published><updated>2010-11-04T05:18:11.925-07:00</updated><title type='text'></title><content type='html'>This comment has been removed by the author.</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6237161444180571452/2008531335235183215/comments/default/6850561369966785841'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6237161444180571452/2008531335235183215/comments/default/6850561369966785841'/><author><name>Argumenten voor kernenergie</name><uri>http://www.blogger.com/profile/04520548262759417956</uri><email>noreply@blogger.com</email><gd:image xmlns:gd='http://schemas.google.com/g/2005' rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:in-reply-to xmlns:thr='http://purl.org/syndication/thread/1.0' href='http://blog.lowkster.com/2010/11/list-comprehension-ruby-vs-python.html' ref='tag:blogger.com,1999:blog-6237161444180571452.post-2008531335235183215' source='http://www.blogger.com/feeds/6237161444180571452/posts/default/2008531335235183215' type='text/html'/><gd:extendedProperty xmlns:gd='http://schemas.google.com/g/2005' name='blogger.contentRemoved' value='true'/><gd:extendedProperty xmlns:gd='http://schemas.google.com/g/2005' name='blogger.itemClass' value='pid-930966641'/></entry><entry><id>tag:blogger.com,1999:blog-6237161444180571452.post-1133859514929458987</id><published>2010-11-04T03:00:38.641-07:00</published><updated>2010-11-04T03:00:38.641-07:00</updated><title type='text'>I don&amp;#39;t like the even and odd thing. Apart fro...</title><content type='html'>I don&amp;#39;t like the even and odd thing. Apart from having English words, there is nothing special about them: why is there no specific function for mod 3 or mod 4 or mod 5 and so on? &lt;br /&gt;In my whole life as a programmer, I never needed &amp;#39;even&amp;#39;, except in simple programming examples. &lt;br /&gt;&lt;br /&gt;In clojure for example there is &amp;#39;when&amp;#39;, &amp;#39;when-not&amp;#39;, &amp;#39;true?&amp;#39;, and &amp;#39;if-not&amp;#39; and I really don&amp;#39;t like that. &lt;br /&gt;It is good that python has no &amp;#39;if-not&amp;#39; &amp;#39;while-not&amp;#39; and so on. It makes a language clearer. If there is &amp;#39;not&amp;#39; and &amp;#39;while&amp;#39; you don&amp;#39;t need a special &amp;#39;while-not&amp;#39;.</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6237161444180571452/2008531335235183215/comments/default/1133859514929458987'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6237161444180571452/2008531335235183215/comments/default/1133859514929458987'/><link rel='alternate' type='text/html' href='http://blog.lowkster.com/2010/11/list-comprehension-ruby-vs-python.html?showComment=1288864838641#c1133859514929458987' title=''/><author><name>stefan-schwarzburg</name><uri>https://launchpad.net/~stefan-schwarzburg</uri><email>noreply@blogger.com</email><gd:image xmlns:gd='http://schemas.google.com/g/2005' rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img1.blogblog.com/img/openid16-rounded.gif'/></author><thr:in-reply-to xmlns:thr='http://purl.org/syndication/thread/1.0' href='http://blog.lowkster.com/2010/11/list-comprehension-ruby-vs-python.html' ref='tag:blogger.com,1999:blog-6237161444180571452.post-2008531335235183215' source='http://www.blogger.com/feeds/6237161444180571452/posts/default/2008531335235183215' type='text/html'/><gd:extendedProperty xmlns:gd='http://schemas.google.com/g/2005' name='blogger.itemClass' value='pid-1325439177'/></entry><entry><id>tag:blogger.com,1999:blog-6237161444180571452.post-2998660351478958981</id><published>2010-11-04T02:13:49.066-07:00</published><updated>2010-11-04T02:13:49.066-07:00</updated><title type='text'>(Saw this through Planet Python)

1. I can&amp;#39;t s...</title><content type='html'>(Saw this through Planet Python)&lt;br /&gt;&lt;br /&gt;1. I can&amp;#39;t see how the ruby version is easier to read, but beauty is in the eye of the beholder.&lt;br /&gt;&lt;br /&gt;2. The ruby version isn&amp;#39;t really a list comprehension (LC). An LC is a language structure, whereas the ruby you&amp;#39;ve posted is applying functions to a list.&lt;br /&gt;&lt;br /&gt;It&amp;#39;s easy to see the difference when both written in the same language. I&amp;#39;ve used Haskell as that&amp;#39;s where Python borrowed LCs from.&lt;br /&gt;&lt;br /&gt;Prelude&amp;gt; [x*3 | x &amp;lt;- [1,2,3,4,5], even x] &lt;br /&gt;[6,12]&lt;br /&gt;&lt;br /&gt;Prelude&amp;gt; map (*3) (filter even [1,2,3,4,5])&lt;br /&gt;[6,12]&lt;br /&gt;&lt;br /&gt;Python put a few more keywords in the LC to make it read better, and Ruby uses a different calling style for functions. You can see how they compare though.&lt;br /&gt;&lt;br /&gt;... and python has map and filter&lt;br /&gt;&lt;br /&gt;&amp;gt;&amp;gt;&amp;gt; map(lambda x: x*3, filter(even, [1,2,3,4,5]))&lt;br /&gt;[6, 12]&lt;br /&gt;&lt;br /&gt;(I predefined the even function. This is in 2.7, in 3.x it returns an iterator. Wrapping it in list() gets you a list)&lt;br /&gt;&lt;br /&gt;So really the only differences between Ruby and Python are:&lt;br /&gt;1) The calling style of functions. f(x) vs x.f&lt;br /&gt;2) The lamba style. lambda x vs |x|&lt;br /&gt;&lt;br /&gt;Other than that you&amp;#39;re comparing LCs to functional style.</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6237161444180571452/2008531335235183215/comments/default/2998660351478958981'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6237161444180571452/2008531335235183215/comments/default/2998660351478958981'/><link rel='alternate' type='text/html' href='http://blog.lowkster.com/2010/11/list-comprehension-ruby-vs-python.html?showComment=1288862029066#c2998660351478958981' title=''/><author><name>Paul Sargent</name><uri>http://weebull.myopenid.com/</uri><email>noreply@blogger.com</email><gd:image xmlns:gd='http://schemas.google.com/g/2005' rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img1.blogblog.com/img/openid16-rounded.gif'/></author><thr:in-reply-to xmlns:thr='http://purl.org/syndication/thread/1.0' href='http://blog.lowkster.com/2010/11/list-comprehension-ruby-vs-python.html' ref='tag:blogger.com,1999:blog-6237161444180571452.post-2008531335235183215' source='http://www.blogger.com/feeds/6237161444180571452/posts/default/2008531335235183215' type='text/html'/><gd:extendedProperty xmlns:gd='http://schemas.google.com/g/2005' name='blogger.itemClass' value='pid-1603989350'/></entry><entry><id>tag:blogger.com,1999:blog-6237161444180571452.post-3596074761170382630</id><published>2010-11-04T00:13:19.165-07:00</published><updated>2010-11-04T00:13:19.165-07:00</updated><title type='text'>I think this is a very subjective assessment. The ...</title><content type='html'>I think this is a very subjective assessment. The python version seems more readable to me without the &amp;#39;line noise&amp;#39; in the ruby version.</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6237161444180571452/2008531335235183215/comments/default/3596074761170382630'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6237161444180571452/2008531335235183215/comments/default/3596074761170382630'/><link rel='alternate' type='text/html' href='http://blog.lowkster.com/2010/11/list-comprehension-ruby-vs-python.html?showComment=1288854799165#c3596074761170382630' title=''/><author><name>Raja</name><uri>http://www.blogger.com/profile/17138871434315349022</uri><email>noreply@blogger.com</email><gd:image xmlns:gd='http://schemas.google.com/g/2005' rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:in-reply-to xmlns:thr='http://purl.org/syndication/thread/1.0' href='http://blog.lowkster.com/2010/11/list-comprehension-ruby-vs-python.html' ref='tag:blogger.com,1999:blog-6237161444180571452.post-2008531335235183215' source='http://www.blogger.com/feeds/6237161444180571452/posts/default/2008531335235183215' type='text/html'/><gd:extendedProperty xmlns:gd='http://schemas.google.com/g/2005' name='blogger.itemClass' value='pid-1584681694'/></entry><entry><id>tag:blogger.com,1999:blog-6237161444180571452.post-1490500209650154588</id><published>2010-11-03T22:14:20.454-07:00</published><updated>2010-11-03T22:14:20.454-07:00</updated><title type='text'>Python has map() as well. The difference to the Py...</title><content type='html'>Python has map() as well. The difference to the Python version is that it&amp;#39;s not needed. Telling someone to map times three onto list x is not more clearer than the python version.&lt;br /&gt;&lt;br /&gt;The &amp;quot;odd&amp;quot; and &amp;quot;even&amp;quot; properties on integers makes this particular example clearer though, but that&amp;#39;s an unusual test in real life.&lt;br /&gt;&lt;br /&gt;Taking every second item sounds more useful:&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;[x*3 for x in [1,2,3,4,5][::2]]</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6237161444180571452/2008531335235183215/comments/default/1490500209650154588'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6237161444180571452/2008531335235183215/comments/default/1490500209650154588'/><link rel='alternate' type='text/html' href='http://blog.lowkster.com/2010/11/list-comprehension-ruby-vs-python.html?showComment=1288847660454#c1490500209650154588' title=''/><author><name>regebro</name><uri>http://regebro.wordpress.com/</uri><email>noreply@blogger.com</email><gd:image xmlns:gd='http://schemas.google.com/g/2005' rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img1.blogblog.com/img/openid16-rounded.gif'/></author><thr:in-reply-to xmlns:thr='http://purl.org/syndication/thread/1.0' href='http://blog.lowkster.com/2010/11/list-comprehension-ruby-vs-python.html' ref='tag:blogger.com,1999:blog-6237161444180571452.post-2008531335235183215' source='http://www.blogger.com/feeds/6237161444180571452/posts/default/2008531335235183215' type='text/html'/><gd:extendedProperty xmlns:gd='http://schemas.google.com/g/2005' name='blogger.itemClass' value='pid-591221988'/></entry><entry><id>tag:blogger.com,1999:blog-6237161444180571452.post-2081064523873247719</id><published>2010-11-03T22:03:51.763-07:00</published><updated>2010-11-03T22:03:51.763-07:00</updated><title type='text'>I may be biased, but my eyes favor the Python vers...</title><content type='html'>I may be biased, but my eyes favor the Python version. I think because of fewer random-ish symbols.&lt;br /&gt;&lt;br /&gt;Anyways, I&amp;#39;ve been doing a bit of C# now, and think the LINQ statements present an interesting alternative. They are a SQL inspired version of the same thing.&lt;br /&gt;&lt;br /&gt;(Forgive me if this isn&amp;#39;t quite valid C#, noob)&lt;br /&gt;From i in numbersVar Where i%2==0 Select i*3&lt;br /&gt;&lt;br /&gt;I&amp;#39;m pretty sure I like this the best, but have only just begun looking into the language that offers it.</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6237161444180571452/2008531335235183215/comments/default/2081064523873247719'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6237161444180571452/2008531335235183215/comments/default/2081064523873247719'/><link rel='alternate' type='text/html' href='http://blog.lowkster.com/2010/11/list-comprehension-ruby-vs-python.html?showComment=1288847031763#c2081064523873247719' title=''/><author><name>Pete</name><uri>http://www.blogger.com/profile/08412350992799282198</uri><email>noreply@blogger.com</email><gd:image xmlns:gd='http://schemas.google.com/g/2005' rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://bp0.blogger.com/_2W5NwLaji8E/SHRIin-YuUI/AAAAAAAAAJc/CekSWud190U/s1600-R/peteicon.jpg'/></author><thr:in-reply-to xmlns:thr='http://purl.org/syndication/thread/1.0' href='http://blog.lowkster.com/2010/11/list-comprehension-ruby-vs-python.html' ref='tag:blogger.com,1999:blog-6237161444180571452.post-2008531335235183215' source='http://www.blogger.com/feeds/6237161444180571452/posts/default/2008531335235183215' type='text/html'/><gd:extendedProperty xmlns:gd='http://schemas.google.com/g/2005' name='blogger.itemClass' value='pid-1699623019'/></entry><entry><id>tag:blogger.com,1999:blog-6237161444180571452.post-307554696187530309</id><published>2010-11-03T20:57:17.843-07:00</published><updated>2010-11-03T20:57:17.843-07:00</updated><title type='text'>[x*3 for x in range(2,6,2)]

The difference in pyt...</title><content type='html'>[x*3 for x in range(2,6,2)]&lt;br /&gt;&lt;br /&gt;The difference in python is that the left hand side tells you what you are going to get and the right hand side is the source.  &amp;quot;I am making a list of multiples of three using a list of numbers...&amp;quot;  The Ruby example starts with the source (the list of numbers) and ends with the sink (multiples of 3).</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6237161444180571452/2008531335235183215/comments/default/307554696187530309'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6237161444180571452/2008531335235183215/comments/default/307554696187530309'/><link rel='alternate' type='text/html' href='http://blog.lowkster.com/2010/11/list-comprehension-ruby-vs-python.html?showComment=1288843037843#c307554696187530309' title=''/><author><name>Jack Diederich</name><uri>http://www.blogger.com/profile/01875505174692466327</uri><email>noreply@blogger.com</email><gd:image xmlns:gd='http://schemas.google.com/g/2005' rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:in-reply-to xmlns:thr='http://purl.org/syndication/thread/1.0' href='http://blog.lowkster.com/2010/11/list-comprehension-ruby-vs-python.html' ref='tag:blogger.com,1999:blog-6237161444180571452.post-2008531335235183215' source='http://www.blogger.com/feeds/6237161444180571452/posts/default/2008531335235183215' type='text/html'/><gd:extendedProperty xmlns:gd='http://schemas.google.com/g/2005' name='blogger.itemClass' value='pid-226612144'/></entry><entry><id>tag:blogger.com,1999:blog-6237161444180571452.post-5365065581296198581</id><published>2010-11-03T20:28:28.958-07:00</published><updated>2010-11-03T20:28:28.958-07:00</updated><title type='text'>This is how i read the python code

[x*3 for x in ...</title><content type='html'>This is how i read the python code&lt;br /&gt;&lt;br /&gt;[x*3 for x in [1,2,3,4,5] if x%2 == 0]&lt;br /&gt;&lt;br /&gt;&amp;quot;give me a list of x*3 for each x in [1,2,3,4,5] where x mod 2 is 0&amp;quot;&lt;br /&gt;&lt;br /&gt;or &lt;br /&gt;&lt;br /&gt;&amp;quot;give me a list of number*3 for each number in [1,2,3,4,5] where number is even&amp;quot;</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6237161444180571452/2008531335235183215/comments/default/5365065581296198581'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6237161444180571452/2008531335235183215/comments/default/5365065581296198581'/><link rel='alternate' type='text/html' href='http://blog.lowkster.com/2010/11/list-comprehension-ruby-vs-python.html?showComment=1288841308958#c5365065581296198581' title=''/><author><name>KageSenshi</name><uri>http://www.blogger.com/profile/00019993555432609309</uri><email>noreply@blogger.com</email><gd:image xmlns:gd='http://schemas.google.com/g/2005' rel='http://schemas.google.com/g/2005#thumbnail' width='26' height='32' src='http://bp0.blogger.com/_0DENAyCRujw/R4ecChwdDBI/AAAAAAAAAIM/9FtwG-EwxRs/S220/hackergotchi.png'/></author><thr:in-reply-to xmlns:thr='http://purl.org/syndication/thread/1.0' href='http://blog.lowkster.com/2010/11/list-comprehension-ruby-vs-python.html' ref='tag:blogger.com,1999:blog-6237161444180571452.post-2008531335235183215' source='http://www.blogger.com/feeds/6237161444180571452/posts/default/2008531335235183215' type='text/html'/><gd:extendedProperty xmlns:gd='http://schemas.google.com/g/2005' name='blogger.itemClass' value='pid-680818116'/></entry></feed>
