Convert all print statements in the docs.
diff --git a/Doc/tutorial/errors.rst b/Doc/tutorial/errors.rst
index e3c631f..aa367e3 100644
--- a/Doc/tutorial/errors.rst
+++ b/Doc/tutorial/errors.rst
@@ -26,7 +26,7 @@
The parser repeats the offending line and displays a little 'arrow' pointing at
the earliest point in the line where the error was detected. The error is
caused by (or at least detected at) the token *preceding* the arrow: in the
-example, the error is detected at the keyword :keyword:`print`, since a colon
+example, the error is detected at the function :func:`print`, since a colon
(``':'``) is missing before it. File name and line number are printed so you
know where to look in case the input came from a script.
@@ -181,8 +181,8 @@
... print(inst.args) # arguments stored in .args
... print(inst) # __str__ allows args to be printed directly
... x, y = inst # __getitem__ allows args to be unpacked directly
- ... print 'x =', x
- ... print 'y =', y
+ ... print('x =', x)
+ ... print('y =', y)
...
<type 'Exception'>
('spam', 'eggs')
@@ -260,7 +260,7 @@
>>> try:
... raise MyError(2*2)
... except MyError as e:
- ... print 'My exception occurred, value:', e.value
+ ... print('My exception occurred, value:', e.value)
...
My exception occurred, value: 4
>>> raise MyError, 'oops!'
diff --git a/Doc/tutorial/floatingpoint.rst b/Doc/tutorial/floatingpoint.rst
index ab68723..2eaab12 100644
--- a/Doc/tutorial/floatingpoint.rst
+++ b/Doc/tutorial/floatingpoint.rst
@@ -85,7 +85,7 @@
you may wish to use that instead. It's unusual for ``eval(str(x))`` to
reproduce *x*, but the output may be more pleasant to look at::
- >>> print str(0.1)
+ >>> print(str(0.1))
0.1
It's important to realize that this is, in a real sense, an illusion: the value
diff --git a/Doc/tutorial/inputoutput.rst b/Doc/tutorial/inputoutput.rst
index 7dc9f74..54f4403 100644
--- a/Doc/tutorial/inputoutput.rst
+++ b/Doc/tutorial/inputoutput.rst
@@ -132,7 +132,7 @@
Using the ``%`` operator looks like this::
>>> import math
- >>> print 'The value of PI is approximately %5.3f.' % math.pi
+ >>> print('The value of PI is approximately %5.3f.' % math.pi)
The value of PI is approximately 3.142.
If there is more than one format in the string, you need to pass a tuple as
@@ -140,7 +140,7 @@
>>> table = {'Sjoerd': 4127, 'Jack': 4098, 'Dcab': 7678}
>>> for name, phone in table.items():
- ... print '%-10s ==> %10d' % (name, phone)
+ ... print('%-10s ==> %10d' % (name, phone))
...
Jack ==> 4098
Dcab ==> 7678
@@ -159,7 +159,7 @@
shown here::
>>> table = {'Sjoerd': 4127, 'Jack': 4098, 'Dcab': 8637678}
- >>> print 'Jack: %(Jack)d; Sjoerd: %(Sjoerd)d; Dcab: %(Dcab)d' % table
+ >>> print('Jack: %(Jack)d; Sjoerd: %(Sjoerd)d; Dcab: %(Dcab)d' % table)
Jack: 4098; Sjoerd: 4127; Dcab: 8637678
This is particularly useful in combination with the new built-in :func:`vars`
diff --git a/Doc/tutorial/interpreter.rst b/Doc/tutorial/interpreter.rst
index 8b42090..ce78399 100644
--- a/Doc/tutorial/interpreter.rst
+++ b/Doc/tutorial/interpreter.rst
@@ -111,7 +111,7 @@
>>> the_world_is_flat = 1
>>> if the_world_is_flat:
- ... print "Be careful not to fall off!"
+ ... print("Be careful not to fall off!")
...
Be careful not to fall off!
@@ -170,6 +170,8 @@
Source Code Encoding
--------------------
+.. XXX out of date!
+
It is possible to use encodings different than ASCII in Python source files. The
best way to do it is to put one more special comment line right after the ``#!``
line to define the source file encoding::
@@ -191,7 +193,7 @@
# -*- coding: iso-8859-15 -*-
currency = u"€"
- print ord(currency)
+ print(ord(currency))
If your editor supports saving files as ``UTF-8`` with a UTF-8 *byte order mark*
(aka BOM), you can use that instead of an encoding declaration. IDLE supports
diff --git a/Doc/tutorial/stdlib2.rst b/Doc/tutorial/stdlib2.rst
index af243f3..3ef21d2 100644
--- a/Doc/tutorial/stdlib2.rst
+++ b/Doc/tutorial/stdlib2.rst
@@ -44,7 +44,7 @@
... a list of strings instead of one big string with newlines to separate
... the wrapped lines."""
...
- >>> print textwrap.fill(doc, width=40)
+ >>> print(textwrap.fill(doc, width=40))
The wrap() method is just like fill()
except that it returns a list of strings
instead of one big string with newlines
@@ -121,7 +121,7 @@
>>> for i, filename in enumerate(photofiles):
... base, ext = os.path.splitext(filename)
... newname = t.substitute(d=date, n=i, f=ext)
- ... print '%s --> %s' % (filename, newname)
+ ... print('%s --> %s' % (filename, newname))
img_1074.jpg --> Ashley_0.jpg
img_1076.jpg --> Ashley_1.jpg
@@ -155,7 +155,7 @@
filename = data[start:start+filenamesize]
start += filenamesize
extra = data[start:start+extra_size]
- print filename, hex(crc32), comp_size, uncomp_size
+ print(filename, hex(crc32), comp_size, uncomp_size)
start += extra_size + comp_size # skip to the next header