is list comprehension necessary?

Michael Torrie torriem at gmail.com
Mon Nov 22 01:57:15 EST 2010


On 10/27/2010 05:37 AM, Roy Smith wrote:
> I agree.  I resisted LCs when they first came out, passing them off as 
> unnecessary, confusing, etc.  Eventually, I came to be comfortable with 
> them and use them often.

I do use LCs fairly often, but only then a for loop would be ugly or
inefficient.  In many cases, I find a normal for loop often is clearer.
 Basically I'm saying that you can over-use LCs.  And sometimes LCs only
serve to make code harder to read.  Just because you can use an LC
doesn't always mean you should.  But of course that's just my opinion.



More information about the Python-list mailing list