[Python-checkins] bpo-47007: [doc] `str` special method lookup (GH-31863)
miss-islington
webhook-mailer at python.org
Mon Apr 4 22:59:13 EDT 2022
https://github.com/python/cpython/commit/c0063bdc7b5fed98c6799f3da0a954a775e3d89e
commit: c0063bdc7b5fed98c6799f3da0a954a775e3d89e
branch: 3.9
author: Miss Islington (bot) <31488909+miss-islington at users.noreply.github.com>
committer: miss-islington <31488909+miss-islington at users.noreply.github.com>
date: 2022-04-04T19:59:04-07:00
summary:
bpo-47007: [doc] `str` special method lookup (GH-31863)
Clarify the `str()` docs to point out that `object.__str__()`
follows special method lookup.
Co-authored-by: Jelle Zijlstra <jelle.zijlstra at gmail.com>
(cherry picked from commit bb86d1d9fbd1888524e04475383f4ea764277f67)
Co-authored-by: Vanshaj Singhania <8797467+itsvs at users.noreply.github.com>
files:
M Doc/library/stdtypes.rst
diff --git a/Doc/library/stdtypes.rst b/Doc/library/stdtypes.rst
index b10909d81af0a..4be4d1daa831d 100644
--- a/Doc/library/stdtypes.rst
+++ b/Doc/library/stdtypes.rst
@@ -1448,7 +1448,8 @@ multiple fragments.
depends on whether *encoding* or *errors* is given, as follows.
If neither *encoding* nor *errors* is given, ``str(object)`` returns
- :meth:`object.__str__() <object.__str__>`, which is the "informal" or nicely
+ :meth:`type(object).__str__(object) <object.__str__>`,
+ which is the "informal" or nicely
printable string representation of *object*. For string objects, this is
the string itself. If *object* does not have a :meth:`~object.__str__`
method, then :func:`str` falls back to returning
More information about the Python-checkins
mailing list