8000 Incorrect prompt strings in The Python Tutorial · Issue #122944 · python/cpython · GitHub
[go: up one dir, main page]

Skip to content

Incorrect prompt strings in The Python Tutorial #122944

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Flyagin opened this issue Aug 12, 2024 · 3 comments · Fixed by #122954
Closed

Incorrect prompt strings in The Python Tutorial #122944

Flyagin opened this issue Aug 12, 2024 · 3 comments · Fixed by #122954
Labels
docs Documentation in the Doc dir easy

Comments

@Flyagin
Copy link
Flyagin commented Aug 12, 2024

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

@Flyagin Flyagin added the docs Documentation in the Doc dir label Aug 12, 2024
@sobolevn sobolevn added the easy label Aug 12, 2024
@sobolevn
Copy link
Member

PR is welcome! 👍

terryjreedy pushed a commit that referenced this issue Aug 12, 2024
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.
miss-islington pushed a commit to miss-islington/cpython that referenced this issue Aug 12, 2024
…ythonGH-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.
(cherry picked from commit be90648)

Co-authored-by: Damien <81557462+Damien-Chen@users.noreply.github.com>
miss-islington pushed a commit to miss-islington/cpython that referenced this issue Aug 12, 2024
…ythonGH-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.
(cherry picked from commit be90648)

Co-authored-by: Damien <81557462+Damien-Chen@users.noreply.github.com>
@terryjreedy
Copy link
Member

Thanks for the report and PR. I have no idea if the REPL ever continued with ... after top level comments, but it definitely does not do so now (3.12+), and docs for 3.x should match 3.x.

terryjreedy pushed a commit that referenced this issue Aug 12, 2024
…GH-122949) (#122955)

gh-122944: Fix incorrect prompt strings in the Python Tutorial (GH-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.
(cherry picked from commit be90648)

Co-authored-by: Damien <81557462+Damien-Chen@users.noreply.github.com>
terryjreedy pushed a commit that referenced this issue Aug 12, 2024
…GH-122949) (#122954)

gh-122944: Fix incorrect prompt strings in the Python Tutorial (GH-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.
(cherry picked from commit be90648)

Co-authored-by: Damien <81557462+Damien-Chen@users.noreply.github.com>
@Flyagin
Copy link
Author
Flyagin commented Aug 12, 2024

Thank you for replies!

blhsing pushed a commit to blhsing/cpython that referenced this issue Aug 22, 2024
…ython#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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
docs Documentation in the Doc dir easy
Projects
None yet
3 participants
0