This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: Wrong output in tutorial (3.1.2. Strings)
Type: Stage: resolved
Components: Documentation Versions: Python 2.7
process
Status: closed Resolution: not a bug
Dependencies: Superseder:
Assigned To: docs@python Nosy List: Amit Amely, docs@python, matrixise, methane, serhiy.storchaka
Priority: normal Keywords:

Created on 2019-02-19 08:45 by Amit Amely, last changed 2022-04-11 14:59 by admin. This issue is now closed.

Messages (7)
msg335905 - (view) Author: Amit Amely (Amit Amely) Date: 2019-02-19 08:45
This is the tutorial text:

>>> prefix = 'Py'
>>> prefix 'thon'  # can't concatenate a variable and a string literal
  ...
SyntaxError: invalid syntax
>>> ('un' * 3) 'ium'
  ...
SyntaxError: invalid syntax

This is the actual result:

>>> prefix = 'Py'
>>> prefix 'thon'  # can't concatenate a variable and a string literal
  File "<stdin>", line 1
    prefix 'thon'  # can't concatenate a variable and a string literal
                ^
SyntaxError: invalid syntax
msg335909 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2019-02-19 08:58
The output in tutorial is correct. "..." means omitted output (we don't want to clutter examples with insignificant details).
msg335912 - (view) Author: Amit Amely (Amit Amely) Date: 2019-02-19 09:27
But it also contains an error message part which has nothing to do with
this example (marked in dark green)

This only works with two literals though, not with variables or expressions:

>>> prefix = 'Py'>>> prefix 'thon'  # can't concatenate a variable and a string literal  ...SyntaxError: invalid syntax>>> ('un' * 3) 'ium'  ...SyntaxError: invalid syntax

If you want to concatenate variables or a variable and a literal, use +:

On Tue, Feb 19, 2019 at 10:58 AM Serhiy Storchaka <report@bugs.python.org>
wrote:

>
> Serhiy Storchaka <storchaka+cpython@gmail.com> added the comment:
>
> The output in tutorial is correct. "..." means omitted output (we don't
> want to clutter examples with insignificant details).
>
> ----------
> nosy: +serhiy.storchaka
> resolution:  -> not a bug
> stage:  -> resolved
> status: open -> closed
>
> _______________________________________
> Python tracker <report@bugs.python.org>
> <https://bugs.python.org/issue36032>
> _______________________________________
>
msg335915 - (view) Author: Stéphane Wirtel (matrixise) * (Python committer) Date: 2019-02-19 09:41
@serhiy

I think Amit wants to say there is no triple point in these examples of the tutorial.
msg335916 - (view) Author: Stéphane Wirtel (matrixise) * (Python committer) Date: 2019-02-19 09:42
and when you execute the examples, the REPL does not generate the triple points.

For me, the examples of the tuto are correct and we don't need to add '...' in the examples.
msg335932 - (view) Author: Inada Naoki (methane) * (Python committer) Date: 2019-02-19 11:47
@Amit Please confirm docs.python.org before submitting issue.
#33460 fixed it already.
msg335933 - (view) Author: Inada Naoki (methane) * (Python committer) Date: 2019-02-19 11:48
Uh!  You meant Python 2.7!!
It doesn't make sense to improve Python 2.7 tutorial.
If you're reading Python 2 tutorial, please read 3.7 tutorial instead!!!
History
Date User Action Args
2022-04-11 14:59:11adminsetgithub: 80213
2019-02-19 11:48:46methanesetmessages: + msg335933
2019-02-19 11:47:35methanesetnosy: + methane
messages: + msg335932
2019-02-19 09:42:54matrixisesetmessages: + msg335916
2019-02-19 09:41:24matrixisesetnosy: + matrixise
messages: + msg335915
2019-02-19 09:27:54Amit Amelysetmessages: + msg335912
2019-02-19 08:58:27serhiy.storchakasetstatus: open -> closed

nosy: + serhiy.storchaka
messages: + msg335909

resolution: not a bug
stage: resolved
2019-02-19 08:45:34Amit Amelycreate