Sitemap

McMillan Enterprises, Inc.
Python Pages
  Sockets HOWTO
  Distributing Python Programs
  A Python C++ API
  Embedding Python
  Stackless Python
  MkSQL
  Import Hooks
Java Samples
About ME Inc.

Python

Python is a highly dynamic, object-oriented programming language with an unusually good balance between power and friendliness.

While often known as a "scripting" language, most practitioners do not see it that way. Unlike languages whose primary purpose is to act as "glue", Python is a full-featured and coherent language that (like many functional languages) encourages you to approach your problem at a higher level of abstraction, while still providing plenty of hooks into the real world.

Why Python?

Python is eminently well suited to the way I like to work. I was trained, first in Stuctured Programming, then in OO, and finally as a "Software Architect" to work exclusively "top-down". But a little introspection and some observation satisfied me years ago that the "top-down only" philosophy is based on a lie. In any designer's mind, he (or she) is (secretly, maybe even unconsciously) doing as much "bottom-up" as "top-down". Otherwise, there is absolutely no way of knowing whether your "top-down" design is at all reasonable. (Well, I've seen some of those, too.)

Python is great at this "top and bottom - towards the middle" style of programming. It takes some discipline - too much "top" can yield a cute class hierarchy that doesn't work; too much "bottom" can yield an ugly kludge. But the fact that one tool does both makes true iterative development a real possibility.

You will hear two common complaints about Python: it's use of whitespace (indentation) for block-delimiting, and the fact that it's "slow".

Whitespace

In reality, and despite the precedent set by make, Python's use of indentation for delimiting blocks is very rarely a problem. As long as the indentation is consistent, Python is happy. When tabs and spaces are mixed, Python uses the rule that 1 tab is 8 spaces, (well, a tab takes you to the next tabstop, with tabstops at 8, 16, ...). Most people like to use an indent level of 4. Fortunately, almost all modern editors allow you to use the tab key and get 4 spaces, so Python need never fall back to these rules. If you find a file with an inconsistent mixture of tabs and spaces, it will normally be visually obvious. It will also normally produce syntax errors instead of incorrect control flow. Executing Python with the -t or -tt options will make if very obvious.

Slowness

...is in the eye of the beholder. As a completely dynamic language, Python is slow at many things. Function call overhead, for example, is enormous compared to many languages. (And Python's I/O and regular expressions will nearly always be bested by Perl.) That doesn't mean that the Python solution to a problem will be unacceptably slow, however. On the contrary - Python makes it easy to experiment with algorithms, and a better algorithm will nearly always give you order-of-magnitude speed ups. If that's still not good enough, it is relatively easy to extend Python by coding some low-level details in C or C++.

The Basics

Staying Current

Finding interesting stuff

My Favorite Extensions

copyright 1999-2002
McMillan Enterprises, Inc.