mirror of
https://github.com/python/cpython.git
synced 2025-07-24 03:35:53 +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
|
@ -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.
|
||||
|
|
|
@ -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:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue