When one enters a string consisting exclusively of a comment [like "# this is a comment" (without quotes)], the next prompt string should be ">>>", and it actually is so in 14 places in 4 files in The Python Tutorial listed below. Yet in 9 other places in 4 files in The Python Tutorial, the next prompt string is "...". I think that it should be corrected. Of course, the "..." prompt string is suitable sometimes, but where? In compound statements, such as while, whereas comments do not belong to this category.
Wrong prompt strings ("...", after strings consisting exclusively of a comment)
introduction.rst
line 503
>>> # Fibonacci series:
... # the sum of two elements defines the next
controlflow.rst
line 63
>>> # Measure some strings:
... words = ['cat', 'window', 'defenestrate']
line 447
>>> # Now call the function we just defined:
... fib(2000)
datastructures.rst
line 385
>>> # Tuples may be nested:
... u = t, (1, 2, 3, 4, 5)
line 389
>>> # Tuples are immutable:
... t[0] = 88888
line 394
>>> # but they can contain mutable objects:
... v = ([1, 2, 3], [3, 2, 1])
line 467
>>> # Demonstrate set operations on unique letters from two words
...
inputoutput.rst
line 89
>>> # The repr() of a string adds string quotes and backslashes:
... hello = 'hello, world\n'
line 94
>>> # The argument to repr() may be any Python object:
... repr((x, y, ('spam', 'eggs')))
Correct prompt strings (">>>", after strings consisting exclusively of a comment)
introduction.rst
line 219
>>> # 3 times 'un', followed by 'ium'
>>> 3 * 'un' + 'ium'
line 461
>>> # replace some values
>>> letters[2:5] = ['C', 'D', 'E']
line 465
>>> # now remove them
>>> letters[2:5] = []
line 469
>>> # clear the list by replacing all the elements with an empty list
>>> letters[:] = []
datastructures.rst
line 252
>>> # create a new list with the values doubled
>>> [x*2 for x in vec]
line 255
>>> # filter the list to exclude negative numbers
>>> [x for x in vec if x >= 0]
line 258
>>> # apply a function to all the elements
>>> [abs(x) for x in vec]
line 261
>>> # call a method on each element
>>> freshfruit = [' banana', ' loganberry ', 'passion fruit ']
line 265
>>> # create a list of 2-tuples like (number, square)
>>> [(x, x**2) for x in range(6)]
line 268
>>> # the tuple must be parenthesized, otherwise an error is raised
>>> [x, x**2 for x in range(6)]
line 274
>>> # flatten a list using a listcomp with two 'for'
>>> vec = [[1,2,3], [4,5,6], [7,8,9]]
inputoutput.rst
line 354
>>> # We can check that the file has been automatically closed.
>>> f.closed
stdlib.rst
line 218
>>> # dates are easily constructed and formatted
>>> from datetime import date
line 226
>>> # dates support calendar arithmetic
>>> birthday = date(1964, 7, 31)
Linked PRs
When one enters a string consisting exclusively of a comment [like "# this is a comment" (without quotes)], the next prompt string should be ">>>", and it actually is so in 14 places in 4 files in The Python Tutorial listed below. Yet in 9 other places in 4 files in The Python Tutorial, the next prompt string is "...". I think that it should be corrected. Of course, the "..." prompt string is suitable sometimes, but where? In compound statements, such as while, whereas comments do not belong to this category.
Wrong prompt strings ("...", after strings consisting exclusively of a comment)
introduction.rst
line 503
controlflow.rst
line 63
line 447
datastructures.rst
line 385
line 389
line 394
line 467
inputoutput.rst
line 89
line 94
Correct prompt strings (">>>", after strings consisting exclusively of a comment)
introduction.rst
line 219
line 461
line 465
line 469
datastructures.rst
line 252
line 255
line 258
line 261
line 265
line 268
line 274
inputoutput.rst
line 354
stdlib.rst
line 218
line 226
Linked PRs