mirror of
https://github.com/python/cpython.git
synced 2025-08-03 08:34:29 +00:00
Convert a lot of print statements to print functions in docstrings,
documentation, and unused/rarely used functions.
This commit is contained in:
parent
8321f97891
commit
752abd0d3c
20 changed files with 53 additions and 50 deletions
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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)::
|
||||
|
||||
|
|
|
@ -104,4 +104,4 @@ Generating a plist::
|
|||
Parsing a plist::
|
||||
|
||||
pl = readPlist(pathOrFile)
|
||||
print pl["aKey"]
|
||||
print(pl["aKey"])
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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()
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue