Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cpython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cpython
Commits
035f7e88
Commit
035f7e88
authored
Dec 19, 2000
by
Guido van Rossum
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Clarify __repr__ and __str__.
parent
5b56765f
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
10 additions
and
7 deletions
+10
-7
Doc/ref/ref3.tex
Doc/ref/ref3.tex
+10
-7
No files found.
Doc/ref/ref3.tex
View file @
035f7e88
...
...
@@ -910,12 +910,15 @@ imported modules are still available at the time when the
\begin{methoddesc}
[object]
{__
repr
__}{
self
}
Called by the
\function
{
repr()
}
\bifuncindex
{
repr
}
built-in function
and by string conversions (reverse quotes) to compute the ``official''
string representation of an object. This should normally look like a
valid Python expression that can be used to recreate an object with
the same value. By convention, objects which cannot be trivially
converted to strings which can be used to create a similar object
produce a string of the form
\samp
{
<
\var
{
...some useful
description...
}
>
}
.
string representation of an object. It at all possible, this should
look like a valid Python expression that could be used to recreate an
object with the same value (given an appropriate environment). If
this is not possible, a string of the form
\samp
{
<
\var
{
...some useful
description...
}
>
}
should be returned. The return value must be a
string object.
This is typically used for debugging, so it is important that the
representation is information-rich and unambiguous.
\indexii
{
string
}{
conversion
}
\indexii
{
reverse
}{
quotes
}
\indexii
{
backward
}{
quotes
}
...
...
@@ -928,7 +931,7 @@ by the \keyword{print}\stindex{print} statement to compute the
``informal'' string representation of an object. This differs from
\method
{__
repr
__
()
}
in that it does not have to be a valid Python
expression: a more convenient or concise representation may be used
instead.
instead.
The return value must be a string object.
\end{methoddesc}
\begin{methoddesc}
[object]
{__
cmp
__}{
self, other
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment