summaryrefslogtreecommitdiff
path: root/Doc
diff options
context:
space:
mode:
authorNeal Norwitz <nnorwitz@gmail.com>2008-05-13 04:55:24 +0000
committerNeal Norwitz <nnorwitz@gmail.com>2008-05-13 04:55:24 +0000
commit83c377dd5990795fa0905d03ea6dc63c700537a0 (patch)
treea904ac41c394c5a9550f81e94f856739305eccc5 /Doc
parent21490dca222db588b54acc5f0824d62f14b2d7e3 (diff)
downloadcpython-83c377dd5990795fa0905d03ea6dc63c700537a0.tar.gz
Convert a lot of print statements to print functions in docstrings,
documentation, and unused/rarely used functions.
Diffstat (limited to 'Doc')
-rw-r--r--Doc/howto/functional.rst6
-rw-r--r--Doc/library/collections.rst2
-rw-r--r--Doc/library/datetime.rst8
-rw-r--r--Doc/library/json.rst10
-rw-r--r--Doc/library/modulefinder.rst16
-rw-r--r--Doc/library/plistlib.rst2
-rw-r--r--Doc/library/sched.rst6
-rw-r--r--Doc/library/socket.rst2
-rw-r--r--Doc/library/wsgiref.rst2
-rw-r--r--Doc/tools/sphinxext/patchlevel.py7
-rw-r--r--Doc/tutorial/datastructures.rst4
-rw-r--r--Doc/tutorial/errors.rst2
12 files changed, 34 insertions, 33 deletions
diff --git a/Doc/howto/functional.rst b/Doc/howto/functional.rst
index faa041843e..c71d0381a4 100644
--- a/Doc/howto/functional.rst
+++ b/Doc/howto/functional.rst
@@ -222,10 +222,10 @@ These two statements are equivalent::
for i in iter(obj):
- print i
+ print(i)
for i in obj:
- print i
+ print(i)
Iterators can be materialized as lists or tuples by using the :func:`list` or
:func:`tuple` constructor functions:
@@ -709,7 +709,7 @@ obvious :keyword:`for` loop::
containing the count and each element. ::
>>> for item in enumerate(['subject', 'verb', 'object']):
- ... print item
+ ... print(item)
(0, 'subject')
(1, 'verb')
(2, 'object')
diff --git a/Doc/library/collections.rst b/Doc/library/collections.rst
index e886d86224..a5cffddede 100644
--- a/Doc/library/collections.rst
+++ b/Doc/library/collections.rst
@@ -232,7 +232,7 @@ Example:
>>> from collections import deque
>>> d = deque('ghi') # make a new deque with three items
>>> for elem in d: # iterate over the deque's elements
- ... print elem.upper()
+ ... print(elem.upper())
G
H
I
diff --git a/Doc/library/datetime.rst b/Doc/library/datetime.rst
index e4aac1a2ec..9401b381b2 100644
--- a/Doc/library/datetime.rst
+++ b/Doc/library/datetime.rst
@@ -532,7 +532,7 @@ Example of working with :class:`date`:
datetime.date(2002, 3, 11)
>>> t = d.timetuple()
>>> for i in t: # doctest: +SKIP
- ... print i
+ ... print(i)
2002 # year
3 # month
11 # day
@@ -544,7 +544,7 @@ Example of working with :class:`date`:
-1
>>> ic = d.isocalendar()
>>> for i in ic: # doctest: +SKIP
- ... print i
+ ... print(i)
2002 # ISO year
11 # ISO week number
1 # ISO day number ( 1 = Monday )
@@ -1011,7 +1011,7 @@ Examples of working with datetime objects:
>>> # Using datetime.timetuple() to get tuple of all attributes
>>> tt = dt.timetuple()
>>> for it in tt: # doctest: +SKIP
- ... print it
+ ... print(it)
...
2006 # year
11 # month
@@ -1025,7 +1025,7 @@ Examples of working with datetime objects:
>>> # Date in ISO format
>>> ic = dt.isocalendar()
>>> for it in ic: # doctest: +SKIP
- ... print it
+ ... print(it)
...
2006 # ISO year
47 # ISO week
diff --git a/Doc/library/json.rst b/Doc/library/json.rst
index 79430c3513..9f1ebc2151 100644
--- a/Doc/library/json.rst
+++ b/Doc/library/json.rst
@@ -17,13 +17,13 @@ Encoding basic Python object hierarchies::
>>> import json
>>> json.dumps(['foo', {'bar': ('baz', None, 1.0, 2)}])
'["foo", {"bar": ["baz", null, 1.0, 2]}]'
- >>> print json.dumps("\"foo\bar")
+ >>> print(json.dumps("\"foo\bar"))
"\"foo\bar"
- >>> print json.dumps(u'\u1234')
+ >>> print(json.dumps(u'\u1234'))
"\u1234"
- >>> print json.dumps('\\')
+ >>> print(json.dumps('\\'))
"\\"
- >>> print json.dumps({"c": 0, "b": 0, "a": 0}, sort_keys=True)
+ >>> print(json.dumps({"c": 0, "b": 0, "a": 0}, sort_keys=True))
{"a": 0, "b": 0, "c": 0}
>>> from StringIO import StringIO
>>> io = StringIO()
@@ -40,7 +40,7 @@ Compact encoding::
Pretty printing::
>>> import json
- >>> print json.dumps({'4': 5, '6': 7}, sort_keys=True, indent=4)
+ >>> print(json.dumps({'4': 5, '6': 7}, sort_keys=True, indent=4))
{
"4": 5,
"6": 7
diff --git a/Doc/library/modulefinder.rst b/Doc/library/modulefinder.rst
index 13ea11d28a..e9043d2f03 100644
--- a/Doc/library/modulefinder.rst
+++ b/Doc/library/modulefinder.rst
@@ -32,7 +32,7 @@ report of the imported modules will be printed.
This class provides :meth:`run_script` and :meth:`report` methods to determine
the set of modules imported by a script. *path* can be a list of directories to
search for modules; if not specified, ``sys.path`` is used. *debug* sets the
- debugging level; higher values make the class print debugging messages about
+ debugging level; higher values make the class print debugging messages about
what it's doing. *excludes* is a list of module names to exclude from the
analysis. *replace_paths* is a list of ``(oldpath, newpath)`` tuples that will
be replaced in module paths.
@@ -82,14 +82,14 @@ The script that will output the report of bacon.py::
finder = ModuleFinder()
finder.run_script('bacon.py')
- print 'Loaded modules:'
- for name, mod in finder.modules.iteritems():
- print '%s: ' % name,
- print ','.join(mod.globalnames.keys()[:3])
+ print('Loaded modules:')
+ for name, mod in finder.modules.items():
+ print('%s: ' % name, end='')
+ print(','.join(mod.globalnames.keys()[:3]))
- print '-'*50
- print 'Modules not imported:'
- print '\n'.join(finder.badmodules.iterkeys())
+ print('-'*50)
+ print('Modules not imported:')
+ print('\n'.join(finder.badmodules.keys()))
Sample output (may vary depending on the architecture)::
diff --git a/Doc/library/plistlib.rst b/Doc/library/plistlib.rst
index 81b10bce0e..a71376ef12 100644
--- a/Doc/library/plistlib.rst
+++ b/Doc/library/plistlib.rst
@@ -104,4 +104,4 @@ Generating a plist::
Parsing a plist::
pl = readPlist(pathOrFile)
- print pl["aKey"]
+ print(pl["aKey"])
diff --git a/Doc/library/sched.rst b/Doc/library/sched.rst
index bb15c76992..e0007fc6fc 100644
--- a/Doc/library/sched.rst
+++ b/Doc/library/sched.rst
@@ -52,14 +52,14 @@ Example::
>>> import time
>>> from threading import Timer
>>> def print_time():
- ... print "From print_time", time.time()
+ ... print("From print_time", time.time())
...
>>> def print_some_times():
- ... print time.time()
+ ... print(time.time())
... Timer(5, print_time, ()).start()
... Timer(10, print_time, ()).start()
... time.sleep(11) # sleep while time-delay events execute
- ... print time.time()
+ ... print(time.time())
...
>>> print_some_times()
930343690.257
diff --git a/Doc/library/socket.rst b/Doc/library/socket.rst
index 9a3af1d71b..d7164dae1d 100644
--- a/Doc/library/socket.rst
+++ b/Doc/library/socket.rst
@@ -866,7 +866,7 @@ the interface::
s.ioctl(socket.SIO_RCVALL, socket.RCVALL_ON)
# receive a package
- print s.recvfrom(65565)
+ print(s.recvfrom(65565))
# disabled promiscuous mode
s.ioctl(socket.SIO_RCVALL, socket.RCVALL_OFF)
diff --git a/Doc/library/wsgiref.rst b/Doc/library/wsgiref.rst
index 55d780fbd9..2437bcd7c3 100644
--- a/Doc/library/wsgiref.rst
+++ b/Doc/library/wsgiref.rst
@@ -132,7 +132,7 @@ parameter expect a WSGI-compliant dictionary to be supplied; please see
return ret
httpd = make_server('', 8000, simple_app)
- print "Serving on port 8000..."
+ print("Serving on port 8000...")
httpd.serve_forever()
diff --git a/Doc/tools/sphinxext/patchlevel.py b/Doc/tools/sphinxext/patchlevel.py
index cb9e35c226..821e3be307 100644
--- a/Doc/tools/sphinxext/patchlevel.py
+++ b/Doc/tools/sphinxext/patchlevel.py
@@ -63,9 +63,10 @@ def get_version_info():
return get_header_version_info('.')
except (IOError, OSError):
version, release = get_sys_version_info()
- print >>sys.stderr, 'Can\'t get version info from Include/patchlevel.h, ' \
- 'using version of this interpreter (%s).' % release
+ print('Can\'t get version info from Include/patchlevel.h, '
+ 'using version of this interpreter (%s).' % release,
+ file=sys.stderr)
return version, release
if __name__ == '__main__':
- print get_header_version_info('.')[1]
+ print(get_header_version_info('.')[1])
diff --git a/Doc/tutorial/datastructures.rst b/Doc/tutorial/datastructures.rst
index 7999e0d152..8e4f05309c 100644
--- a/Doc/tutorial/datastructures.rst
+++ b/Doc/tutorial/datastructures.rst
@@ -239,7 +239,7 @@ lists, one list per row::
Now, if you wanted to swap rows and columns, you could use a list
comprehension::
- >>> print [[row[i] for row in mat] for i in [0, 1, 2]]
+ >>> print([[row[i] for row in mat] for i in [0, 1, 2]])
[[1, 4, 7], [2, 5, 8], [3, 6, 9]]
Special care has to be taken for the *nested* list comprehension:
@@ -251,7 +251,7 @@ A more verbose version of this snippet shows the flow explicitly::
for i in [0, 1, 2]:
for row in mat:
- print row[i],
+ print(row[i], end="")
print
In real world, you should prefer builtin functions to complex flow statements.
diff --git a/Doc/tutorial/errors.rst b/Doc/tutorial/errors.rst
index a9687e5fbc..66213c5577 100644
--- a/Doc/tutorial/errors.rst
+++ b/Doc/tutorial/errors.rst
@@ -132,7 +132,7 @@ the exception (allowing a caller to handle the exception as well)::
s = f.readline()
i = int(s.strip())
except IOError as (errno, strerror):
- print "I/O error(%s): %s" % (errno, strerror)
+ print("I/O error(%s): %s" % (errno, strerror))
except ValueError:
print("Could not convert data to an integer.")
except: