Message351771
"The implementation adds a few special read-only attributes to several object TYPES" [emphasis added]
py> class MyType:
... pass
...
py> MyType.__dict__ = {}
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
AttributeError: attribute '__dict__' of 'type' objects is not writable
> What is the difference between an object and an instance?
In general, nothing. But ``object.__dict__`` refers to the special builtin *class* called "object". In hindsight, we should have called it Object, so we could more easily distinguish between the *class* called "object" and *instances* of that class.
py> print(object) # the class/type itself
<class 'object'>
py> print(object()) # an instance of object
<object object at 0xb7ce1cd0>
The docs are correct here, but if you care to suggest some improvements, we will consider them. |
|
Date |
User |
Action |
Args |
2019-09-11 08:57:58 | steven.daprano | set | recipients:
+ steven.daprano, docs@python, reed |
2019-09-11 08:57:58 | steven.daprano | set | messageid: <1568192278.26.0.984037092262.issue38099@roundup.psfhosted.org> |
2019-09-11 08:57:58 | steven.daprano | link | issue38099 messages |
2019-09-11 08:57:58 | steven.daprano | create | |
|