An object is an instance (or not)?
ben+python at benfinney.id.au
Tue Jan 27 23:32:09 CET 2015
Mario Figueiredo <marfig at gmail.com> writes:
> People were saying to me that in Python object = instance. I'm trying
> to argue why I believe it isn't and asking for arguments to convince
> me otherwise.
* Every value is an object.
* Every object is an instance of some class.
* To say “object” is uproblematic for values in Python, because the
programming term “object” doesn't imply anything about classes.
* To say “instance” implies a specific relationship to some particular
class; in programming terminology (because in English generally) an
instance is so called only because it is an instance of some specific
> By referring to an instance of Sub as "Sub object", there's an
> implicit affirmation that an object is an instance.
Correct. That raises a fourth point:
* In the distant past of Python, some objects were not instances of any
class; the terminology in the documentation and messages shows some
confusing legacies from that ancient time.
The phrasing “'Foo' object” is ambiguous in a way that “'Foo' instance”
would not be. I agree with others that changing the message to refer to
“'Foo' instance” would be an improvement.
\ “Pinky, are you pondering what I'm pondering?” “I think so, |
`\ Brain, but I find scratching just makes it worse.” —_Pinky and |
_o__) The Brain_ |
More information about the Python-list