Issue 36032: Wrong output in tutorial (3.1.2. Strings) (original) (raw)

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 "", 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:11 admin set github: 80213
2019-02-19 11:48:46 methane set messages: +
2019-02-19 11:47:35 methane set nosy: + methanemessages: +
2019-02-19 09:42:54 matrixise set messages: +
2019-02-19 09:41:24 matrixise set nosy: + matrixisemessages: +
2019-02-19 09:27:54 Amit Amely set messages: +
2019-02-19 08:58:27 serhiy.storchaka set status: open -> closednosy: + serhiy.storchakamessages: + resolution: not a bugstage: resolved
2019-02-19 08:45:34 Amit Amely create