python anti-rant

April 15, 2005

Looking at clee’s not-so-obvious complaint against python I see a couple of issues.

foo = [‘one’, ‘two’, ‘three’]

foo.reverse()

for i in foo:

print i

His complaint is that this is un-intuitive to him. So I’m a bit confused. Why would I make a new list just to get the current list reversed? It seems more intuitive me that you want something done to the list then you call the method of the list object that performs that item INTERNALLY to the object. Why should the reverse() method also return the list. I only told it to reverse it. This seems MORE intuitive to me than the way perl or ruby are handling it b/c perl and ruby are both doing:

reverse() == reverse() && return()

He is also upset b/c for dict objects it seems inconsistent for python to have iteritems() be an available method. I think this has more to do with the implementation of iterators after python 2.2 and less to do with any goals in the language. Moreover for getting a simple list of dictionary keys or values he could, of course, just use dict.keys() or dict.values().

Finally, he bemoans the lack of a ternary operator. I think the lack of ternary operator is a plus. It just means we do not have an operation with no keywords just floating separated by random line noise. I consider it a readability benefit.

If only we can find another way of writing lambdas and maps that were as efficient as lambdas or maps we’d be rid of the next ugliest operation.

All in all his complaints seem summed up by: “I’m used to other languages that go out of their way to make things terser and more confusing by using random line noise characters therefore I’m confused by a language that makes readability a priority.”

It’s a shame when an otherwise perfectly good programmer is broken by other languages.

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 )

Twitter picture

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

Facebook photo

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

Google+ photo

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

Connecting to %s

%d bloggers like this: