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: Python Documentation on strings (tutorial section 3.1.2.)
Type: Stage: resolved
Components: Documentation Versions:
process
Status: closed Resolution: not a bug
Dependencies: Superseder:
Assigned To: docs@python Nosy List: Deshpande, docs@python, iritkatriel, mark.dickinson
Priority: normal Keywords:

Created on 2019-07-12 20:50 by Deshpande, last changed 2022-04-11 14:59 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
Python_Docs_3.1.2_String_Concatination.py Deshpande, 2019-07-12 20:50 File has python code that demonstrates string concatination works not only on the strings but also on the variables. It also shows that the strings expressions also can be used.
Messages (3)
msg347754 - (view) Author: Srikanth (Deshpande) Date: 2019-07-12 20:50
In section 3.1.2 of the python documentation, its mentioned as below:

Two or more string literals (i.e. the ones enclosed between quotes) next to each other are automatically concatenated.
This feature is particularly useful when you want to break long strings:
This only works with two literals though, not with variables or expressions:

However, the concatination operation works on variables and expressions also.
Please find the below python code snippet and the output:

Python Code:
-------------
s1='Hello'
s2=' World '
s3=' How are you ? '
print(s1, s2, "\n", s3, "\n")
print('---------------------------')
print('Long time ' 'No see mate ')
print("Hope ", 'All is ' "good")
print('---------------------------')
print(s1, 'World'," !!")
print((s1+s2+s3)*2," there ?")


Output:
--------
Hello  World                                                                                                          
  How are you ?                                                                                                       
                                                                                                                      
---------------------------                                                                                           
Long time No see mate                                                                                                 
Hope  All is good                                                                                                     
---------------------------                                                                                           
Hello World  !!                                                                                                       
Hello World  How are you ? Hello World  How are you ?   there ?
msg347756 - (view) Author: Mark Dickinson (mark.dickinson) * (Python committer) Date: 2019-07-12 21:16
The documentation is correct here; none of the examples you show demonstrates implicit concatenation of string-valued expressions.
The tutorial documentation is referring to two strings placed
directly next to each other with no other syntax (other than
whitespace) in between.

For example, taking just the first line you give (after the definitions):

    print(s1, s2, "\n", s3, "\n")

Nowhere in this line are two string-value expressions placed right next
to each other; they're occurring in an argument list to a function,
separated by commas. The other lines are similar.
msg377101 - (view) Author: Irit Katriel (iritkatriel) * (Python committer) Date: 2020-09-18 09:37
I think this issue can be closed (not a bug).
History
Date User Action Args
2022-04-11 14:59:17adminsetgithub: 81756
2020-09-18 15:34:42zach.waresetstatus: open -> closed
stage: resolved
2020-09-18 09:37:17iritkatrielsetstatus: pending -> open
nosy: + iritkatriel
messages: + msg377101

2019-07-13 13:32:12mark.dickinsonsetstatus: open -> pending
resolution: not a bug
type: resource usage ->
2019-07-12 21:17:55mark.dickinsonsettitle: Python Documentation on strings ( section 3.1.2.) -> Python Documentation on strings (tutorial section 3.1.2.)
2019-07-12 21:16:02mark.dickinsonsetnosy: + mark.dickinson
messages: + msg347756
2019-07-12 20:50:07Deshpandecreate