classes vs. modules vs. types

Skip Montanaro (
Mon, 2 May 1994 17:35:40 GMT

I'm just getting started with Python and am wondering what distinctions, if
any, there are between modules, classes, and built-in types. I'm interested
in understanding how I might integrate C++ classes into Python. To add some
concreteness to my problem, suppose I have a simple C++ class hierarchy:


Shape is abstract and defines getcolor() and setcolor() methods, and
declares a single abstract virtual method, getarea(). Circle, rectangle, and
triangle must define getarea().

Would each class be treated as a module or would the four classes together
be a single module? Are there any examples of classes written in C, or is
that not possible? (Must classes be written in the scripting language?) If
so, are classes written in C considered equivalent to built-in types?

I looked at the code in posixmodule.c and arraymodule.c. The former seems to
provide few class concepts (e.g., no ability to create new objects at
run-time), just a new namespace (posix) populated with a bunch of
functions. The array module is much more complicated. Is the creating of a
complex module like "array" documented somewhere?


Skip (