Python is a relatively new,
interpreted, object oriented very high level programming language which
can be used for a wide range of applications. Python has many advanced
- Dynamic typing.
- Dynamic binding (local variables are in current version
bound statically for speed). Names are bound in order:
local, module, global. Class attributes have to be referenced
by the object they belong to.
- Associative arrays (in Python they are called dictionaries)
and nice list handling.
- Module concept (additional name scope layers).
- About everything in Python is an object or it can be used as
one. Classes have several 'default' methods with which one
can set/change what happens with class initialization,
deletion, coersion, algebra, attribute access etc.
- Python code could be described as self-documenting as
functions, classes and modules all have documentation
attribute containing quoted text at the start of code and
you can access a dictionary containing all the modules,
classes, functions and variables in the module and so on.
- Multiple inheritance (inheritance in order superclasses are
declared in the class declaration).
- Good exception handling. Users can define their own exceptions
just by giving exception name for a string. Exeception classes
work just as well of course.
- Run-time checks for things like array subscripts.
- Standard Python distribution includes profiler and debugger,
both written completely in Python...
- Offers signals, sockets, regular expressions and interfaces
to external utilities like SQL databases via python libarary.
- There's a numerical version of Python that offers builtin
capabilies for manipulating vectors and matrices. From
version 1.4 onwards standard python contains builtin complex
- Easy to expand or imbed with/in other languages, especially
if OS supports dynamic linking. This way you'll get both
the usability of Python and the speed of a lower level
language like C++. There's a program called SWIG for
creating wrappers to code/libraries done on other languages.
- Available on about all platforms. Python source is ANSI-C
and very platform independent (because garbage collection is
quite platform dependent, Python core and extensions use
reference counting). There are versions for most unix
platforms (best supported), Windows (DOS, 3.11, 95, NT), Mac
and even for ones like Amiga and Atari. VMS port is on the
- Threading on platforms that support it.
- Oncoming CORBA (distributed objects) support and portable
GUI module (based on Tk). There are also interfaces based
on native GUI programming interfaces (eg. COM and MFC).
- For WWW usage Python has modules dealing with CGIs and
different protocols, a NetScape plugin and there's even a
HTML-2 compliant WWW browser done in python.
- When running Python scripts, security can be garanteed with
namespace restriction. This way programmer has
complete control over which parts of the
Python core and library (and through them OS and file
system too) are revealed for the scripts.
- Extensive tutorial, library reference and language extension
in HTML, PostScript and LaTeX formats.
- Comp.lang.python newsgroup is one of the best I have read.
Most mailings are interesting (topics differ greatly:
OOPla, memory handling in interpreters, numerical
calculation issues, style guides, `AI' you name it). There
are no `serious' flamewars and silly beginner's questions
are very rare.
- Lots of source code examples for variety of CS subjects.
For example lazy evaluation, meta programming, distributed
computing and so on.
- Despite being copyrighted by Stichting Matematisch Centrum,
Amsterdam, Python and it's sources are freely usable, free
of charge, commercially or otherwise. License is quite
similar to BSD one.
Python and Perl
As the main Python namespace is so sparse, users are encouraged to use
modules and classes. This way Python beginners will model their
programs structuredly from start almost without noticing it. And the
way how things work in Python is IMHO very intuitive. Python objects
offer same kind of interface for doing similar jobs. Builtin and
standard Python operations which modify the `argument' object
are normally methods, and other operations are (also available as)
If we compare Python and Perl, two internally very similar languages
which also offer about the same functionality, we'll notice that their
programming filosofies differ greatly. Whereas Perl concentrates on
efficiency, Python tries first to be simple (=elegant) and structured.
Neither of them enforces user to that, though.
Making easily maintainable code in Perl needs much stronger coding guide
lines and dicipline than in Python, in which that sort of grows out of
the nature of the language (orthogonality). Part of Perl's efficiency
comes from there being many different ways for making slightly different
things, but that way Python progammer and maintainer have to be much
more intimate with the Perl language. I personally find the practise of
doing different operations for a variable based on how variable is
written(!) slightly revolting...
Python and C++
C++ has a lot of baggage from C. It's understandable, but makes the
language `un-clean'. Therefore users can more easily make lousy code.
Templates try to emulate dynamic binding and Standard Template Library,
which is nowadays part of the `standard' C++, offers C++ similar
functionality (`containers' and `iterators') as lists and dictionaries
offer for Python. Python syntax is just cleaner and simpler to use.
For example, Python `for' loops operate over a range like list (`for obj
in objects: obj.draw()').
The reasons for using statically bound languages are:
but especially pointer operations are much more prone to errors.
- programs are much faster
- programs use less memory
- speed and memory usage are more predictable
- static typechecking finds programming errors earlier. With
dynamic bindind you'll need more test suites.
Python is a good candinate for application prototyping. Time-critical
parts of the program could be changed into ones compiled with statically
bound language as they get ready, until (almost) whole program is done
on faster language. Python's extendability (through `C-interface')
makes this quite easy. `Cooked up' python with scripts using it should
be well suited for inside tools (especially for ones which need to
change often) even if that wouldn't be acceptable for a sold product.
On a multiplatform enviroment scripts have certain advantages over
Although dynamically bound languages are normally at least order of a
magnitude slower than statically bound ones, one should note that
`naive' algorithms may also be an order of magnitude slower than
`sophisticated' (= more efficient, not necessarily larger or more
Python and Java
Python could be used for similar things as Java. Python's namespace
restriction based security model is much more versatile and IMHO elegant
than Java's. And although Java is cleaner than C++, it can't beat
Python (Am I biased? That's my right! :-)). Although Python isn't
much older than Java, it's available for far more wider range of
computers as thread support is optional (actually thread support isn't
yet very well integraged into the interpreter). For using Python instead
of Java we need `just' to make a Python -> Java bytecode converter /
interpreter. For now you could use COM and ILU to `program Java' with
Here are all my Python programs. They are
in chronological order and first ones are pretty low level for Python
- A sample player module for Kay
Roemer's MiNT audio device with the
generic Python audiodev interface.
- Implementation of the basic W library
functionality. It's composed of two main modules and a couple
of examples, making lot of use of socket and struct modules:
- wlib.py implements all the socket
communication with the W server and contains get_event()
function, Font class and the Window baseclass.
- wgraph.py contains a Graph class
that implements the requests for W graphics primitives
through the Window baseclass.
- turtle.py implements simple turtle graphics
(remember Logo?) class on top of the Graph class.
- wtest.py includes two test functions for
the Window and Graph classes.
- An simple L-system parser (a
grammar based system in which each token denotes some
geometrical action on grammar visualization) that can have
different grammars / translations. Currently I have implemented
grammars for W and POV (raytracer) output. Code looks a bit ugly
- I wanted to experiment a little more with sockets in a more
Pythonesque manner so I implemented a chat server and client.
They are used a bit like one channel IRC and composed of
- chat.py implements a very simple class for
sending and receiving little packets over a socket in
pieces. This is used by both the server and client.
- chatsrv.py is the server.
It makes use of many of the Python's niftiest features.
Commands offered for the clients are: /help, /nick, /name,
/address, /who, /msg and /calc. Last one executes given
string as a python script in the math module enviroment and
sends the result back to the client.
- chatclt.py is a simple client program. It
includes two interfaces for testing the server, a text one
(-> no line editing capabilities) and a W window one using
the above mentioned Graph class. You might have fun
implementing an interface for your own native GUI. You could
also implent the client in some other language.
Python on Atari platform
Chris Herborth has ported
Python v1.3 for MiNT (available on most Atari ftp-sites like umich). I have myself
converted a couple of Python documents to formats better accessable on
- ST-Guide version of
the Aaron Watters' Python tutorial.
This is a bit Un*x oriented, but funny...
- `Quickref-1.3.html' in ASCII
format is faster / less memory consuming to view than
the HTML version... This and some library references are
all you need to start up experimenting with Python.
Some links grabbed from Python newsgroup which I need to check out:
Here are some of the people on board the Python starship: :-)
Hmm... I wonder whether the amazing tim-petersly-yours is also one of
the crew? ;-)
Btw. AFAIK Guido Rossum borrowed the name of the language from `The
Monty Python Circus' comedy group name. Although Python logo is now a
bespectacled snake, here are interpretions for word `python' listed in
the Webster's Encyclopedic Unabridged Dictionary of the English
I would have liked more of a bespectacled (like Guido) dragon than
snake, but I guess that would be harder to put onto script icons... :-)
- A spirit or demon or prophesying person possessed by such.
- Any of several Old World constrictors of family Boidae.
- A large dragon guarding the chasm at Delphi from which the
prophetic vapours emerged. (mythological)
Python, the language that wraps itself around a
problem to squeeze out a solution, swallowing it whole -- Aaron Watters