mirror of
https://github.com/python/cpython.git
synced 2025-11-01 18:51:43 +00:00
bpo-28315: Improve code examples in docs (GH-1372)
Replace File "<stdin>", line 1, in ? with File "<stdin>", line 1, in <module>
This commit is contained in:
parent
a5c62a8e9f
commit
8856940cf2
12 changed files with 30 additions and 30 deletions
|
|
@ -784,7 +784,7 @@ using the :func:`next` built-in function; this example shows how it all works::
|
|||
'c'
|
||||
>>> next(it)
|
||||
Traceback (most recent call last):
|
||||
File "<stdin>", line 1, in ?
|
||||
File "<stdin>", line 1, in <module>
|
||||
next(it)
|
||||
StopIteration
|
||||
|
||||
|
|
|
|||
|
|
@ -475,7 +475,7 @@ Here's an example that fails due to this restriction::
|
|||
...
|
||||
>>> function(0, a=0)
|
||||
Traceback (most recent call last):
|
||||
File "<stdin>", line 1, in ?
|
||||
File "<stdin>", line 1, in <module>
|
||||
TypeError: function() got multiple values for keyword argument 'a'
|
||||
|
||||
When a final formal parameter of the form ``**name`` is present, it receives a
|
||||
|
|
|
|||
|
|
@ -261,7 +261,7 @@ it must be parenthesized. ::
|
|||
[(0, 0), (1, 1), (2, 4), (3, 9), (4, 16), (5, 25)]
|
||||
>>> # the tuple must be parenthesized, otherwise an error is raised
|
||||
>>> [x, x**2 for x in range(6)]
|
||||
File "<stdin>", line 1, in ?
|
||||
File "<stdin>", line 1, in <module>
|
||||
[x, x**2 for x in range(6)]
|
||||
^
|
||||
SyntaxError: invalid syntax
|
||||
|
|
|
|||
|
|
@ -362,7 +362,7 @@ attempts to use the file object will automatically fail. ::
|
|||
>>> f.close()
|
||||
>>> f.read()
|
||||
Traceback (most recent call last):
|
||||
File "<stdin>", line 1, in ?
|
||||
File "<stdin>", line 1, in <module>
|
||||
ValueError: I/O operation on closed file
|
||||
|
||||
It is good practice to use the :keyword:`with` keyword when dealing with file
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue