Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(1862)

Side by Side Diff: Doc/reference/datamodel.rst

Issue 15580: fix True/False/None reST markup
Patch Set: Created 10 months, 2 weeks ago
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
View unified diff | Download patch
« no previous file with comments | « Doc/reference/compound_stmts.rst ('k') | Doc/reference/expressions.rst » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 1268 matching lines...) Expand 10 before | Expand all | Expand 10 after
1279 definition. Doing so means that not only will instances of the class raise an 1279 definition. Doing so means that not only will instances of the class raise an
1280 appropriate :exc:`TypeError` when a program attempts to retrieve their hash 1280 appropriate :exc:`TypeError` when a program attempts to retrieve their hash
1281 value, but they will also be correctly identified as unhashable when checking 1281 value, but they will also be correctly identified as unhashable when checking
1282 ``isinstance(obj, collections.Hashable)`` (unlike classes which define their 1282 ``isinstance(obj, collections.Hashable)`` (unlike classes which define their
1283 own :meth:`__hash__` to explicitly raise :exc:`TypeError`). 1283 own :meth:`__hash__` to explicitly raise :exc:`TypeError`).
1284 1284
1285 If a class that overrides :meth:`__eq__` needs to retain the implementation 1285 If a class that overrides :meth:`__eq__` needs to retain the implementation
1286 of :meth:`__hash__` from a parent class, the interpreter must be told this 1286 of :meth:`__hash__` from a parent class, the interpreter must be told this
1287 explicitly by setting ``__hash__ = <ParentClass>.__hash__``. Otherwise the 1287 explicitly by setting ``__hash__ = <ParentClass>.__hash__``. Otherwise the
1288 inheritance of :meth:`__hash__` will be blocked, just as if :attr:`__hash__` 1288 inheritance of :meth:`__hash__` will be blocked, just as if :attr:`__hash__`
1289 had been explicitly set to :const:`None`. 1289 had been explicitly set to ``None``.
1290 1290
1291 1291
1292 .. note:: 1292 .. note::
1293 1293
1294 By default, the :meth:`__hash__` values of str, bytes and datetime 1294 By default, the :meth:`__hash__` values of str, bytes and datetime
1295 objects are "salted" with an unpredictable random value. Although they 1295 objects are "salted" with an unpredictable random value. Although they
1296 remain constant within an individual Python process, they are not 1296 remain constant within an individual Python process, they are not
1297 predictable between repeated invocations of Python. 1297 predictable between repeated invocations of Python.
1298 1298
1299 This is intended to provide protection against a denial-of-service caused 1299 This is intended to provide protection against a denial-of-service caused
(...skipping 765 matching lines...) Expand 10 before | Expand all | Expand 10 after
2065 2065
2066 Enter the runtime context related to this object. The :keyword:`with` stateme nt 2066 Enter the runtime context related to this object. The :keyword:`with` stateme nt
2067 will bind this method's return value to the target(s) specified in the 2067 will bind this method's return value to the target(s) specified in the
2068 :keyword:`as` clause of the statement, if any. 2068 :keyword:`as` clause of the statement, if any.
2069 2069
2070 2070
2071 .. method:: object.__exit__(self, exc_type, exc_value, traceback) 2071 .. method:: object.__exit__(self, exc_type, exc_value, traceback)
2072 2072
2073 Exit the runtime context related to this object. The parameters describe the 2073 Exit the runtime context related to this object. The parameters describe the
2074 exception that caused the context to be exited. If the context was exited 2074 exception that caused the context to be exited. If the context was exited
2075 without an exception, all three arguments will be :const:`None`. 2075 without an exception, all three arguments will be ``None``.
2076 2076
2077 If an exception is supplied, and the method wishes to suppress the exception 2077 If an exception is supplied, and the method wishes to suppress the exception
2078 (i.e., prevent it from being propagated), it should return a true value. 2078 (i.e., prevent it from being propagated), it should return a true value.
2079 Otherwise, the exception will be processed normally upon exit from this metho d. 2079 Otherwise, the exception will be processed normally upon exit from this metho d.
2080 2080
2081 Note that :meth:`__exit__` methods should not reraise the passed-in exception ; 2081 Note that :meth:`__exit__` methods should not reraise the passed-in exception ;
2082 this is the caller's responsibility. 2082 this is the caller's responsibility.
2083 2083
2084 2084
2085 .. seealso:: 2085 .. seealso::
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
2166 2166
2167 .. rubric:: Footnotes 2167 .. rubric:: Footnotes
2168 2168
2169 .. [#] It *is* possible in some cases to change an object's type, under certain 2169 .. [#] It *is* possible in some cases to change an object's type, under certain
2170 controlled conditions. It generally isn't a good idea though, since it can 2170 controlled conditions. It generally isn't a good idea though, since it can
2171 lead to some very strange behaviour if it is handled incorrectly. 2171 lead to some very strange behaviour if it is handled incorrectly.
2172 2172
2173 .. [#] For operands of the same type, it is assumed that if the non-reflected me thod 2173 .. [#] For operands of the same type, it is assumed that if the non-reflected me thod
2174 (such as :meth:`__add__`) fails the operation is not supported, which is why the 2174 (such as :meth:`__add__`) fails the operation is not supported, which is why the
2175 reflected method is not called. 2175 reflected method is not called.
OLDNEW
« no previous file with comments | « Doc/reference/compound_stmts.rst ('k') | Doc/reference/expressions.rst » ('j') | no next file with comments »

RSS Feeds Recent Issues | This issue
This is Rietveld cbc36f91f3f7