An object is an instance (or not)?
greg.ewing at canterbury.ac.nz
Wed Jan 28 08:21:12 CET 2015
Mario Figueiredo wrote:
> That error message has me start that thread arguing that the error is
> misleading because the Sub object does have the __bases__ attribute.
> It's the Sub instance object that does not have it.
> Some of the answers that were given argued that in Python object =
No, they pointed out that *in that particular sentence* the
word "object" was being used in a way that's more or less
synonymous with "instance".
But that doesn't mean the two words are perfectly
interchangeable in all English sentences. Sometimes one
is better than the other.
I prefer to use the word "instance" when I'm talking about
an instance *of* something, e.g. "an instance of Foo" or
"a Foo instance". If I'm not mentioning a class, I just
use the word "object".
So I would argue that "Sub instance has no attribute..."
is a marginally clearer way to word that message.
Which means, I think, that I'm more or less agreeing with
you, but *not* because of objects not always being instances
in Python. On the contrary, it's precisely because all
objects *are* instances that using the word "instance"
on its own in place of "object" is pointless -- it
doesn't convey any extra information.
More information about the Python-list