In the pre 2.2 world, we essentially had three kinds of objects to play with - we had the:
types (list, tuple, string, etc. - these were built-into Python.)
classes (any classes that we defined)
instances (the third kind of objects)
Types and classes were known not to socialize, and you couldn't create new types. The new (2.2 and later) system moves around many of the old rules, and it is best to start afresh to understand it better. From here on we only discuss the new system.
So what exactly is an object? An object is an axiom in our system - it is the notion of some thing. However, we still define an object by saying it has:
identity (i.e. given two names we can say for sure if they are one and the same object, or not)
attributes (i.e. we can reach other objects through
objectname.attributename)relationships (these are just attributes, but special because Python knows about them). There are basically two of these (elaborated later):
type - every object has exactly one type.
bases - some objects may have more or one bases.
name (the name of the object, some may have more than one, some may have none)
This brings us to our first rule.
Not to be taken too seriously, but this rule does make an important
point. The list, tuple
and string built-ins are objects. Any classes that
we define are objects, and of course, instances of those classes are
objects as well. Yet, as we will see, all objects are not equal. We
keep the notion of objects and relationships at this point and move
on.