An object is an instance (or not)?

Steven D'Aprano steve+comp.lang.python at pearwood.info
Wed Jan 28 04:28:14 EST 2015


Mario Figueiredo wrote:

> In article <mailman.18191.1422400930.18130.python-list at python.org>,
> ned at nedbatchelder.com says...
>> 
>> A common mistake is to believe that "OOP" is a well-defined term.  It's
>> not it's a collection of ideas that are expressed slightly differently
>> in each language.
> 
> A common mistake is thinking just because OOP has different
> implementations, it doesn't have a cohesive set of well described rules
> and its own well defined terminology.

Alas, this is not a mistake. As I posted in a reply to Ben, OOP does not 
have a cohesive set of rules and well-defined terminology.


>> I don't know what a "not fully realized object" is.
> 
> A fully realized object, in an object oriented paradigm, is an object
> containing or pointing to data and the methods to act on that data. It's
> an instance of a class.

In Python, classes meet that definition too. A class in Python is a value 
which can contain data (or point to data), and it has methods which act on 
that data. Classes in Python themselves have a class, which we call the 
metaclass, and classes inherit behaviour from their class just as integer 
instances inherit behaviour from their class, int.


> A *not* fully realized object is possible in Python, since Classes are
> first-class objects, despite not being able to participate in OOP.
> 
>> 
>> What does "participate in OOP" mean?
> 
> Means the object is capable of participating in inheritance and/or
> polymorphism. An instance of an object is capable of doing so, per its
> class definitions. Whereas a Python class object is not.

Class objects are capable of participating in inheritance. A class can have 
multiple metaclasses. They can even have multiple inheritance of 
metaclasses.

I'm not sure what relevance polymorphism has.



-- 
Steven




More information about the Python-list mailing list