A problem with some OO code.

Terry Hancock hancock at anansispaceworks.com
Sun Feb 5 20:21:35 EST 2006


On 4 Feb 2006 09:51:22 -0800
"TPJ" <tprimke at interia.pl> wrote:
> 1) In OO vocabulary, class is something like template for
> an object. But I think the word "object" has something
> different meaning in Python. In general I don't use the
> word "object" in the same meaning, that it is used by
> Python. I try to use words in the same way, that they
> are used in OO.
> Sometimes I use the word "class" to talk about template
> (for an object), and the word "instance" to talk about an
> object of some class, but the only reason I do it is to
> distinguish between OO-object and Python-object.

"Object" in fact means *exactly* the same thing in Python
that it does in any other OOP language.  The only issue is
that *anything*, even simple things like integers, are
*objects* in Python. So, saying "object" (versus something
else) doesn't mean much that we didn't already know -- if
the program can manipulate it, then it's an "object".

Saying a "class instance" or just "instance" for short is a
way of specifically saying that it is a *user defined
object* that we are talking about, created from a "class"
(of course the "class" is *also* an object, and you can even
make objects that make classes -- I think that's what a
"metaclass" is, though I get fuzzy past that point). Usually
the point, though, is to draw attention to what class it is
an instance of.

A class *is* probably describable as a "template" for an
object, although the word "template" has a technical
meaning, too, IIRC, which might not be totally consistent
with that.  More to the point, though, classes are "instance
factories" in Python.  It's almost as if a class is nothing
more than a special category of functions that return
instances.

I don't know if I've helped at all, but I hope so. ;-)

Cheers,
Terry

-- 
Terry Hancock (hancock at AnansiSpaceworks.com)
Anansi Spaceworks http://www.AnansiSpaceworks.com




More information about the Python-list mailing list