Classes and Python
aahz at panix.com
Thu Jan 24 11:34:28 EST 2002
In article <2jc05usg0sic5f9evcdfsa9jebecvkmb93 at 4ax.com>,
Lawrence Oluyede <rhymes at myself.com> wrote:
>I'm a newbie of Python and I'm still reading its tutorial (downloaded
>from the official site).
>I've found this sentence:
>I also have to warn you that there's a terminological pitfall for
>object-oriented readers: the word ``object'' in Python does not
>necessarily mean a class instance. Like C++ and Modula-3, and unlike
>Smalltalk, not all types in Python are classes: the basic built-in
>types like integers and lists are not, and even somewhat more exotic
>types like files aren't. However, all Python types share a little bit
>of common semantics that is best described by using the word object.
>What's the real meaning of that?
The real meaning is that if you're using the current Python 2.2, it's
But it's probably still worthwhile to explain it:
Let's suppose you create a list with
now you can add a new element to L with
this means that L has object-like behavior, in that there are methods
that can be used. But you cannot subclass from the list type in
versions of Python prior to 2.2 -- this is called the type/class split.
Python 2.2 takes the first steps to heal the type/class split, and you
*can* now inherit from the list type.
--- Aahz <*> (Copyright 2002 by aahz at pobox.com)
Hugs and backrubs -- I break Rule 6 http://www.rahul.net/aahz/
Androgynous poly kinky vanilla queer het Pythonista
"I support family values -- Addams family values" --www.nancybuttons.com
More information about the Python-list