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
c77e24b2
Commit
c77e24b2
authored
Aug 07, 2007
by
Guido van Rossum
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Kill references to tp_print.
parent
346f1a82
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
6 additions
and
13 deletions
+6
-13
Doc/ext/newtypes.tex
Doc/ext/newtypes.tex
+6
-13
No files found.
Doc/ext/newtypes.tex
View file @
c77e24b2
...
...
@@ -1151,23 +1151,16 @@ my_dealloc(PyObject *obj)
\subsection
{
Object Presentation
}
In Python, there are three ways to generate a textual representation
of an object: the
\function
{
repr
()
}
\bifuncindex
{
repr
}
function
(
or
equivalent back
-
tick syntax
)
, the
\function
{
str
()
}
\bifuncindex
{
str
}
function, and the
\keyword
{
print
}
statement. For most objects, the
\keyword
{
print
}
statement is equivalent to the
\function
{
str
()
}
function, but it is possible to special
-
case printing to a
\ctype
{
FILE
*
}
if necessary; this should only be done if efficiency is
identified as a problem and profiling suggests that creating a
temporary string object to be written to a file is too expensive.
In Python, there are two ways to generate a textual representation
of an object: the
\function
{
repr
()
}
\bifuncindex
{
repr
}
function, and
the
\function
{
str
()
}
\bifuncindex
{
str
}
function.
(
The
\keyword
{
print
}
function just calls
\function
{
str
()
}
.
)
These handlers are all optional, and most types at most need to
implement the
\member
{
tp
_
str
}
and
\member
{
tp
_
repr
}
handlers.
These handlers are both optional.
\begin
{
verbatim
}
reprfunc tp
_
repr;
reprfunc tp
_
str;
printfunc tp
_
print;
\end
{
verbatim
}
The
\member
{
tp
_
repr
}
handler should return a string object containing
...
...
@@ -1750,7 +1743,7 @@ In order to learn how to implement any specific method for your new
data type, do the following: Download and unpack the Python source
distribution. Go the
\file
{
Objects
}
directory, then search the
C source files for
\code
{
tp
_}
plus the function you want
(
for
example,
\code
{
tp
_
print
}
or
\code
{
tp
_
compare
}
)
. You will find
example,
\code
{
tp
_
compare
}
)
. You will find
examples of the function you want to implement.
When you need to verify that an object is an instance of the type
...
...
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