Text Processing in Python

ludo, Friday 05 September 2003 10:58:00

My current technical reading is the excellent book Text Processing in Python by David Mertz. In chapter 1 David expresses with his usual clarity a couple of concepts I usually unconsciously follow in my Python programming, but which are important enough to be repeat here as a reminder to myself.

[...] an important principle of Python programming makes types less important than programmers coming from other languages tend to expect. According to Python's "principle of pervasive polymorphism" (my own coinage), it is more important what an object does than what it is.

David then proceeds to describe a few practical cases where pervasive polymorphism is useful, like working on file-like objects.

One common way to test a capability in Python is to try to do something, and catch any exceptions that occur (then try something else).

One of the main reasons why I like Python so much compared to other languages is the incredible usefulness of its exception mechanism. After all, many of the things we experiment or learn in life we do by trial and error, and using this same method in programming just fits your brain.

Readers' Comments

No user comments.