Newbie with some doubts.

Terry Hancock hancock at anansispaceworks.com
Sat Jan 7 20:49:26 CET 2006


On 4 Jan 2006 17:36:54 -0800
"Edgar A. Rodriguez" <edgar.antonio.rv at gmail.com> wrote:
> Im newbie to Python (I found it three weeks ago) , in fact
> Im newbie to programming. I'm being reading and training
> with the language, but I still wondering about what
> Classes are used to. Could you please give me some
> examples??

When you imagine a procedural program, you imagine the
computer (the object) following a list of instructions.

When you write an object-oriented program, you are imagining
a model of a more complex imaginary machine with many
interacting objects that does what you want. The parts of
the machine are "class instances" in Python, and each *type*
of part is a "class".  You will also use "classes" and
"class instances" to model data that the program handles.

An object-oriented program is something like a simulation.

This is really useful for programs that do more than just
chug along on a piece of data until they start (which is
sort of the visual model that most people had in mind when
procedural programs were in ascendence).  A program that you
interact with needs to act more flexibly, and evolve as you
work with it.  It also needs to compartmentalize separate
pieces of functionality so that they don't interfere with
each other.

We call these things "class instances" in Python instead of
"objects", because "object" applies to *all data* in
Python, even simple things like the number '1'.  Class
instances are specifically objects defined as a member of a
class.

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




More information about the Python-list mailing list