mirror of
https://github.com/python/cpython.git
synced 2025-11-25 04:34:37 +00:00
gh-122944: Fix incorrect prompt strings in the Python Tutorial (#122949)
In the REPL, top level comments are followed by a primary, not secondary prompt. Fix the places in the in the tutorial that use the latter.
This commit is contained in:
parent
1795d6ceba
commit
be90648fb2
4 changed files with 10 additions and 10 deletions
|
|
@ -61,7 +61,7 @@ they appear in the sequence. For example (no pun intended):
|
||||||
::
|
::
|
||||||
|
|
||||||
>>> # Measure some strings:
|
>>> # Measure some strings:
|
||||||
... words = ['cat', 'window', 'defenestrate']
|
>>> words = ['cat', 'window', 'defenestrate']
|
||||||
>>> for w in words:
|
>>> for w in words:
|
||||||
... print(w, len(w))
|
... print(w, len(w))
|
||||||
...
|
...
|
||||||
|
|
@ -445,7 +445,7 @@ boundary::
|
||||||
... print()
|
... print()
|
||||||
...
|
...
|
||||||
>>> # Now call the function we just defined:
|
>>> # Now call the function we just defined:
|
||||||
... fib(2000)
|
>>> fib(2000)
|
||||||
0 1 1 2 3 5 8 13 21 34 55 89 144 233 377 610 987 1597
|
0 1 1 2 3 5 8 13 21 34 55 89 144 233 377 610 987 1597
|
||||||
|
|
||||||
.. index::
|
.. index::
|
||||||
|
|
|
||||||
|
|
@ -383,16 +383,16 @@ A tuple consists of a number of values separated by commas, for instance::
|
||||||
>>> t
|
>>> t
|
||||||
(12345, 54321, 'hello!')
|
(12345, 54321, 'hello!')
|
||||||
>>> # Tuples may be nested:
|
>>> # Tuples may be nested:
|
||||||
... u = t, (1, 2, 3, 4, 5)
|
>>> u = t, (1, 2, 3, 4, 5)
|
||||||
>>> u
|
>>> u
|
||||||
((12345, 54321, 'hello!'), (1, 2, 3, 4, 5))
|
((12345, 54321, 'hello!'), (1, 2, 3, 4, 5))
|
||||||
>>> # Tuples are immutable:
|
>>> # Tuples are immutable:
|
||||||
... t[0] = 88888
|
>>> t[0] = 88888
|
||||||
Traceback (most recent call last):
|
Traceback (most recent call last):
|
||||||
File "<stdin>", line 1, in <module>
|
File "<stdin>", line 1, in <module>
|
||||||
TypeError: 'tuple' object does not support item assignment
|
TypeError: 'tuple' object does not support item assignment
|
||||||
>>> # but they can contain mutable objects:
|
>>> # but they can contain mutable objects:
|
||||||
... v = ([1, 2, 3], [3, 2, 1])
|
>>> v = ([1, 2, 3], [3, 2, 1])
|
||||||
>>> v
|
>>> v
|
||||||
([1, 2, 3], [3, 2, 1])
|
([1, 2, 3], [3, 2, 1])
|
||||||
|
|
||||||
|
|
@ -465,7 +465,7 @@ Here is a brief demonstration::
|
||||||
False
|
False
|
||||||
|
|
||||||
>>> # Demonstrate set operations on unique letters from two words
|
>>> # Demonstrate set operations on unique letters from two words
|
||||||
...
|
>>>
|
||||||
>>> a = set('abracadabra')
|
>>> a = set('abracadabra')
|
||||||
>>> b = set('alacazam')
|
>>> b = set('alacazam')
|
||||||
>>> a # unique letters in a
|
>>> a # unique letters in a
|
||||||
|
|
|
||||||
|
|
@ -87,12 +87,12 @@ Some examples::
|
||||||
>>> print(s)
|
>>> print(s)
|
||||||
The value of x is 32.5, and y is 40000...
|
The value of x is 32.5, and y is 40000...
|
||||||
>>> # The repr() of a string adds string quotes and backslashes:
|
>>> # The repr() of a string adds string quotes and backslashes:
|
||||||
... hello = 'hello, world\n'
|
>>> hello = 'hello, world\n'
|
||||||
>>> hellos = repr(hello)
|
>>> hellos = repr(hello)
|
||||||
>>> print(hellos)
|
>>> print(hellos)
|
||||||
'hello, world\n'
|
'hello, world\n'
|
||||||
>>> # The argument to repr() may be any Python object:
|
>>> # The argument to repr() may be any Python object:
|
||||||
... repr((x, y, ('spam', 'eggs')))
|
>>> repr((x, y, ('spam', 'eggs')))
|
||||||
"(32.5, 40000, ('spam', 'eggs'))"
|
"(32.5, 40000, ('spam', 'eggs'))"
|
||||||
|
|
||||||
The :mod:`string` module contains a :class:`~string.Template` class that offers
|
The :mod:`string` module contains a :class:`~string.Template` class that offers
|
||||||
|
|
|
||||||
|
|
@ -501,8 +501,8 @@ together. For instance, we can write an initial sub-sequence of the
|
||||||
as follows::
|
as follows::
|
||||||
|
|
||||||
>>> # Fibonacci series:
|
>>> # Fibonacci series:
|
||||||
... # the sum of two elements defines the next
|
>>> # the sum of two elements defines the next
|
||||||
... a, b = 0, 1
|
>>> a, b = 0, 1
|
||||||
>>> while a < 10:
|
>>> while a < 10:
|
||||||
... print(a)
|
... print(a)
|
||||||
... a, b = b, a+b
|
... a, b = b, a+b
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue