| OLD | NEW |
| 1 | 1 |
| 2 .. _datamodel: | 2 .. _datamodel: |
| 3 | 3 |
| 4 ********** | 4 ********** |
| 5 Data model | 5 Data model |
| 6 ********** | 6 ********** |
| 7 | 7 |
| 8 | 8 |
| 9 .. _objects: | 9 .. _objects: |
| 10 | 10 |
| (...skipping 1246 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1257 appropriate :exc:`TypeError` when a program attempts to retrieve their hash | 1257 appropriate :exc:`TypeError` when a program attempts to retrieve their hash |
| 1258 value, but they will also be correctly identified as unhashable when checking | 1258 value, but they will also be correctly identified as unhashable when checking |
| 1259 ``isinstance(obj, collections.Hashable)`` (unlike classes which define their | 1259 ``isinstance(obj, collections.Hashable)`` (unlike classes which define their |
| 1260 own :meth:`__hash__` to explicitly raise :exc:`TypeError`). | 1260 own :meth:`__hash__` to explicitly raise :exc:`TypeError`). |
| 1261 | 1261 |
| 1262 If a class that overrides :meth:`__eq__` needs to retain the implementation | 1262 If a class that overrides :meth:`__eq__` needs to retain the implementation |
| 1263 of :meth:`__hash__` from a parent class, the interpreter must be told this | 1263 of :meth:`__hash__` from a parent class, the interpreter must be told this |
| 1264 explicitly by setting ``__hash__ = <ParentClass>.__hash__``. Otherwise the | 1264 explicitly by setting ``__hash__ = <ParentClass>.__hash__``. Otherwise the |
| 1265 inheritance of :meth:`__hash__` will be blocked, just as if :attr:`__hash__` | 1265 inheritance of :meth:`__hash__` will be blocked, just as if :attr:`__hash__` |
| 1266 had been explicitly set to :const:`None`. | 1266 had been explicitly set to :const:`None`. |
| 1267 |
| 1268 See also the :option:`-R` command-line option. |
| 1267 | 1269 |
| 1268 | 1270 |
| 1269 .. method:: object.__bool__(self) | 1271 .. method:: object.__bool__(self) |
| 1270 | 1272 |
| 1271 .. index:: single: __len__() (mapping object method) | 1273 .. index:: single: __len__() (mapping object method) |
| 1272 | 1274 |
| 1273 Called to implement truth value testing and the built-in operation | 1275 Called to implement truth value testing and the built-in operation |
| 1274 ``bool()``; should return ``False`` or ``True``. When this method is not | 1276 ``bool()``; should return ``False`` or ``True``. When this method is not |
| 1275 defined, :meth:`__len__` is called, if it is defined, and the object is | 1277 defined, :meth:`__len__` is called, if it is defined, and the object is |
| 1276 considered true if its result is nonzero. If a class defines neither | 1278 considered true if its result is nonzero. If a class defines neither |
| (...skipping 781 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2058 | 2060 |
| 2059 .. rubric:: Footnotes | 2061 .. rubric:: Footnotes |
| 2060 | 2062 |
| 2061 .. [#] It *is* possible in some cases to change an object's type, under certain | 2063 .. [#] It *is* possible in some cases to change an object's type, under certain |
| 2062 controlled conditions. It generally isn't a good idea though, since it can | 2064 controlled conditions. It generally isn't a good idea though, since it can |
| 2063 lead to some very strange behaviour if it is handled incorrectly. | 2065 lead to some very strange behaviour if it is handled incorrectly. |
| 2064 | 2066 |
| 2065 .. [#] For operands of the same type, it is assumed that if the non-reflected me
thod | 2067 .. [#] For operands of the same type, it is assumed that if the non-reflected me
thod |
| 2066 (such as :meth:`__add__`) fails the operation is not supported, which is why
the | 2068 (such as :meth:`__add__`) fails the operation is not supported, which is why
the |
| 2067 reflected method is not called. | 2069 reflected method is not called. |
| OLD | NEW |