Things that bug me about Python

Python, love it or hate it, is a bizarre mix of procedural, functional, and object-oriented syntax. There are lots of things to like about it, but also lots of things to dislike. Here are some of my peeves. I’m sure I’m not the only one.


What do Windows and Python have in common? Everyone uses the prior, obsolete version and whines about the new version. Python 3 has been out for what, five years now, and people still prefer Python 2.x for everything?

Is version 3.x the Vista of Python?


This is a set of three numbers: {1, 2, 3}
This is a set of three strings: {‘pizza’, ‘hot dog’, ‘soda’}
This is not the empty set: {}. No, that’s a dictionary. What you meant to write was set(), of course.

Speaking of dictionaries…
Use braces to define an empty dictionary:
>>> D = {}
Use square brackets to access it.
>>> D[‘foo’] = ‘bar’
>>> D[‘foo’]
But get the contents of the dictionary and see it using braces:
>>> D
{‘foo’: ‘bar’}
Sometimes you have to use a method with dictionaries:
>>> D.keys()
And other times you must use a function:
>>> len(D)

The Perl monger in me dies a little bit when I see that.


Want to convert a string into a list of characters? Use the list function, which I guess is OK:
>>> list(‘hello’)
[‘h’, ‘e’, ‘l’, ‘l’, ‘o’]

Want to convert that list back into a string? Use the join method of a string object:
>>> ”.join([‘h’, ‘e’, ‘l’, ‘l’, ‘o’])


Want to give your language the impression that it’s slow: make the primary user interface as glacial as possible. Why is IDLE scrolling sooooo slow?

How about porting a native GUI toolkit to Python so it doesn’t have to rely on Tck/Tk? I can’t tell you how much frustration me and my students have had because the Tk implementation was borked, or there was some weird interaction between Python and Tk. At least Python 3.3.3 for the Mac comes with Tk built in now, but it has bloated the download size tremendously.

But then again…

I’ve still chosen to use Python 3 in my discrete structures course. It has a rich set of datatypes (lists, sets, tuples), comprehensions, a REPL, is cross-platform, is a “cool” and “hip” language, and amazes Java programmers with its handling of large integers.

I just try not to show my students the dark underbelly parts of Python that drives me crazy.


One thought on “Things that bug me about Python

Leave a Reply

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

You are commenting using your 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