misuse of the word “love”

I was coding up a Python script to do some data analysis, and I accomplished with some not-all-that-clever list comprehensions what would otherwise have taken a few lines of for loop to accomplish. And I was pleased, and quoth unto myself, “Gosh, I love list comprehensions.”

Then I thought, “Wait, am I just using list comprehensions just to accomplish in Python what I could accomplish in Matlab with clever indexing tricks?” And I looked upon my code, and it was so.

This is not necessarily a win for Matlab — list comprehensions presumably have more general uses than indexing tricks, and the only reason I have ever bothered to use them is that I’m used to being able to grab sections of lists with one-liners even when the way I’m subdividing those lists is a little complicated. And given that I can do what I want with one-liners in either setting, Python’s overall neatness and superior text-processing utilities give it the win. In this context, which is perhaps retrospectively obvious, since what I’m doing is mathematically light and text-processing heavy. But I spent so long using Matlab as default general-purpose programming language that these things still strike me from time to time.


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s