On 1/27/15 3:12 PM, Mario Figueiredo wrote:
This is a follow up from a previous discussion in which it is argued that the following code produces the correct error message terminology, considering that in Python an object is also an instance.
I don't know what the difference is between "object" and "instance". An object is an instance of a class. The two words are interchangeable as far as I know.
An instance IS an object. On that we can agree. After all, everything in Python is an object. Even classes are. We can even pass them as function arguments: >>> class Sub: pass >>> def show(aClass): print(type(aClass)) >>> show(Sub) <class 'type'> The problem is that an object isn't always an instance. The word instance in OOP has a very formal meaning.
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.
In programming languages in which the classes aren't fully realized objects, it is ok to speak of 'instance' and 'object' interchangeably.
I don't know what a "not fully realized object" is.
But even then, sometimes the term 'object instance' is preferred, as a way to separate these 'instances' from other variable instances that may not be created from class definitions (e.g. C++ built-in types). The fact that in Python classes are objects, should not just eliminate this distinction. The OOP terminology should exist beyond the language implementing it. It facilitates discourse and helps transmiting concepts when describing your ideas to another programmer. And because in python, classes are of the type 'type' and they exist as fully realized objects, is no excuse to make a distinction between them and their own fully realized instances. The language implementation details should not exist as a way for us to freely reformulate long standing terms. Because, from my own study of Python, I've came to realize that the distinction between objects and instances of objects actually exists. In Python, class objects cannot participate in OOP, only their instances.
What does "participate in OOP" mean?
This is why I say that even in Python, where a class is an object, an object is not always an instance. The language itself forces that distinction.
-- Ned Batchelder, http://nedbatchelder.com -- https://mail.python.org/mailman/listinfo/python-list