Three Axioms of Python: Part I

Introduction to List Comprehensions
An Excursion Into Lisp
List Comprehension Useful Tips and Tricks
The Monty Hall Problem

Developers who use Python often highlight the minimalist nature of its syntax as one of the main reasons they like it: the amount of stuff you have to know to be effective in the language is unbelievably small.

Understanding just three Python ideas: list comprehensions, tuples, and name spaces instantly transports you to the level of facility with the language that takes months to achieve in many others. The choice of syntax for a programming language is much akin to the choice of axiom sets in mathematics: though it is ultimately arbitrary, a useful criterion for selecting one set of axioms over another is the richness of its implications — the amount of interesting theorems that can be derived from it. Judged on this basis, Python is impressive: the yield of interesting implications per pound of syntax is very attractive.

It is true that there are other languages with syntax that is even more minimal. However, the sheer minimality is not the object — in that sense nothing can beat a good old Turing machine. What makes Python effective is not just the fact that its base syntax is terse, but that the code that can be naturally and easily derived from it happens to be the stuff a programmer actually does on daily basis.

Although understanding these three “axioms” (list comprehensions, tuples, and name spaces) is central to writing Pythonic code, they can be a bit counter-intuitive to programmers coming from other languages, and, since Python makes it easy to avoid using them, it is quite possible to program in Python for years without gaining true fluency. This is a three part series of posts that focuses on demonstrating the utility of these concepts with practical examples. Read the rest here

submit to reddit
Add this Article to Stumbleupon Add this Article to Digg Add this Article to