[Tutor] what is an object?
glingl at aon.at
Fri Feb 27 19:23:52 EST 2004
Christopher Spears schrieb:
> I have a very
>fundamental question to ask. What exactly is an
>object? A part of my understands what an object is,
>but I cannot articulate this to another person.
Hmm, the most fundamental questions tend to be the most difficult
ones to answer. So I'm certainly not the right person for this and were
it only because of my limited ability to express my thoughts in proper
Nevertheless I'll try to give you a few (unordered) remarks. There are
certainly others on the list, who will give you more complete and more
(0) I assume you want to know what an object in Python is - not in real
life (ore in some other computer language - the concepts differ ...)
(1) In Python (nearly) everything is an object.
(1') An object is the representation of some*thing* you can
think of, or you can find in the real world, in your computer.
What means nearly? The following is *not* an object
*but* a statement:
def __init__(self, name):
But if this statement is executed by the Python interpreter you have
- the possibility to produce new objects:
obj1 = A("Frank")
obj2 = A("Jude")
now obj1 and obj2 are objects.
- and you've got another new object:
sorry, this is a class-object. (I'm anxious that we now are
at a point, where further explanation will make things
make more unclear than clear - and that beeing content
with a more superficial explanation ist the right thing here ...)
If you think of something to be an object, you always
can use the built-in function type to determine which
type (sort) of object it is:
>>> class A:
>>> obj1 = A("Frank")
>>> obj2 = A("Jude")
One disitinction you should observe is the difference
between built-in objects - "types" - an user defined objects
produced by a user defined class.
Since nearly everything is an object, it'Äs hard to chracterize
objects because there are so much differen flavours.
Perhaps what is important to note is:
many of them can take part on operations like +, *, etc....
or as you saw operations with  like a ....
Many of them have attributes.
(a) instance attributes (which are not "callable")
(b) and methods, which represent the ability of objects to perform some
and are essentially functions bound to their objects ...
>>> "hoo gaz gar".split()
['hoo', 'gaz', 'gar']
Think about this now, read more answers certainly to come
from others and think about them for a few days. Then
determine what you want to clarify next and come back
with your next "objects-centered" question.
>Tutor maillist - Tutor at python.org
More information about the Tutor