[issue36032] Wrong output in tutorial (3.1.2. Strings)

2019-02-19 Thread Amit Amely


New submission from Amit Amely :

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

--
assignee: docs@python
components: Documentation
messages: 335905
nosy: Amit Amely, docs@python
priority: normal
severity: normal
status: open
title: Wrong output in tutorial (3.1.2. Strings)
versions: Python 2.7

___
Python tracker 
<https://bugs.python.org/issue36032>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue36032] Wrong output in tutorial (3.1.2. Strings)

2019-02-19 Thread Amit Amely


Amit Amely  added the comment:

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 
wrote:

>
> Serhiy Storchaka  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 
> <https://bugs.python.org/issue36032>
> ___
>

--

___
Python tracker 
<https://bugs.python.org/issue36032>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com