summaryrefslogtreecommitdiffstats
path: root/Doc/extending
diff options
context:
space:
mode:
authorGeorg Brandl <georg@python.org>2007-09-04 07:15:32 (GMT)
committerGeorg Brandl <georg@python.org>2007-09-04 07:15:32 (GMT)
commit6911e3ce3f72af759908b869b73391ea00d328e2 (patch)
tree5d4ff6070cb3f0f46f0a31ee4805b41053a06b48 /Doc/extending
parentc9879246a2dd33a217960496fdf4606cb117c6a6 (diff)
downloadcpython-6911e3ce3f72af759908b869b73391ea00d328e2.zip
cpython-6911e3ce3f72af759908b869b73391ea00d328e2.tar.gz
cpython-6911e3ce3f72af759908b869b73391ea00d328e2.tar.bz2
Convert all print statements in the docs.
Diffstat (limited to 'Doc/extending')
-rw-r--r--Doc/extending/embedding.rst6
-rw-r--r--Doc/extending/newtypes.rst34
2 files changed, 6 insertions, 34 deletions
diff --git a/Doc/extending/embedding.rst b/Doc/extending/embedding.rst
index b9a567c..a50c008 100644
--- a/Doc/extending/embedding.rst
+++ b/Doc/extending/embedding.rst
@@ -64,7 +64,7 @@ perform some operation on a file. ::
{
Py_Initialize();
PyRun_SimpleString("from time import time,ctime\n"
- "print 'Today is',ctime(time())\n");
+ "print('Today is', ctime(time()))\n");
Py_Finalize();
return 0;
}
@@ -141,7 +141,7 @@ array. If you compile and link this program (let's call the finished executable
:program:`call`), and use it to execute a Python script, such as::
def multiply(a,b):
- print "Will compute", a, "times", b
+ print("Will compute", a, "times", b)
c = 0
for i in range(0, a):
c = c + b
@@ -234,7 +234,7 @@ These two lines initialize the ``numargs`` variable, and make the
With these extensions, the Python script can do things like ::
import emb
- print "Number of arguments", emb.numargs()
+ print("Number of arguments", emb.numargs())
In a real application, the methods will expose an API of the application to
Python.
diff --git a/Doc/extending/newtypes.rst b/Doc/extending/newtypes.rst
index c8e49fe..0c035ba 100644
--- a/Doc/extending/newtypes.rst
+++ b/Doc/extending/newtypes.rst
@@ -826,11 +826,11 @@ increases an internal counter. ::
>>> import shoddy
>>> s = shoddy.Shoddy(range(3))
>>> s.extend(s)
- >>> print len(s)
+ >>> print(len(s))
6
- >>> print s.increment()
+ >>> print(s.increment())
1
- >>> print s.increment()
+ >>> print(s.increment())
2
.. literalinclude:: ../includes/shoddy.c
@@ -1063,34 +1063,6 @@ Here is a simple example::
obj->obj_UnderlyingDatatypePtr->size);
}
-The print function will be called whenever Python needs to "print" an instance
-of the type. For example, if 'node' is an instance of type TreeNode, then the
-print function is called when Python code calls::
-
- print node
-
-There is a flags argument and one flag, :const:`Py_PRINT_RAW`, and it suggests
-that you print without string quotes and possibly without interpreting escape
-sequences.
-
-The print function receives a file object as an argument. You will likely want
-to write to that file object.
-
-Here is a sample print function::
-
- static int
- newdatatype_print(newdatatypeobject *obj, FILE *fp, int flags)
- {
- if (flags & Py_PRINT_RAW) {
- fprintf(fp, "<{newdatatype object--size: %d}>",
- obj->obj_UnderlyingDatatypePtr->size);
- }
- else {
- fprintf(fp, "\"<{newdatatype object--size: %d}>\"",
- obj->obj_UnderlyingDatatypePtr->size);
- }
- return 0;
- }
Attribute Management