Why I use Python and enjoy it thoroughly

13 June 2012 Tagged: python development

I started learning Python about a year ago for a web development project during the summer break (but that’s another story). The thing that pulled me in was Django, but I’ve since sticked with Python for a number of projects, both on and offline. So that’s how I got started.

The philosophy

Python is best described in PEP 20 (Python Enhancement Proposal) where we find 19 guiding principles which form the basis of its philosophy. I reproduce them here as they are printed through the Python shell:

>>> import this
The Zen of Python, by Tim Peters

Beautiful is better than ugly.
Explicit is better than implicit.
Simple is better than complex.
Complex is better than complicated.
Flat is better than nested.
Sparse is better than dense.
Readability counts.
Special cases aren't special enough to break the rules.
Although practicality beats purity.
Errors should never pass silently.
Unless explicitly silenced.
In the face of ambiguity, refuse the temptation to guess.
There should be one-- and preferably only one --obvious way to do it.
Although that way may not be obvious at first unless you're Dutch.
Now is better than never.
Although never is often better than *right* now.
If the implementation is hard to explain, it's a bad idea.
If the implementation is easy to explain, it may be a good idea.
Namespaces are one honking great idea -- let's do more of those!


I really like Python’s syntax and forced indentation. It was strange at first, but it grew into me quite quickly because it nudged me into a ritual of structured code with a consistent presentation. Also, the language is really expressive with lots of syntactic sugar and a couple of keywords which make reading source very fluid and easier to quickly grasp.

Versatility (multiple paradigms)

There’s OOP, but you’re not forced into it. Coming from C I only ever use a class if it I feel like it would actually bring me an advantage. I never liked the seas of initializations, getters and setters when a quick function would do the job pretty well. This amazing talk makes a very compelling argument on this point. I do like having the option to use classes (and I do use them!), but mixing them in good old imperative code is much more pleasant. As for functional programming, I try to tell myself that using map() and reduce() qualifies me but deep down I know that’s just a lie. You can however make lots of stuff more functional within Python, and that’s a nice option to have.

Fast to iterate and packed with juice

Being much more high-level and letting you play on the REPL makes Python really fun, but it also empowers you to build stuff that works in much less time than what I was previously used to. Powerful one liners through list comprehensions, cool generators and native types of lists, tuples, sets and dictionaries make developing stuff a joy. The standard library is also pretty cool and packed with nifty functionality from database interfaces to data compression libraries to a bunch of internet protocol clients, you name it.


If what you want is not in the standard library, there’s a good change that you can find what you need in a library somewhere. Somewhere is usually just a pip command away, which is a really awesome packet manager. Other than that, it feels like everyone and their mothers wrote a bit of Python at some point, so its really likely that you’ll find a good answer to whatever question you might have posted out there on the interwebs.

So that’s why I use Python!