From: Miss Islington (bot) <31488909+miss-islington@users.noreply.github.com> Date: Fri, 24 Nov 2017 17:35:53 +0000 (-0800) Subject: Improve the String tutorial docs (GH-4541) (GH-4546) X-Git-Tag: v2.7.15rc1~115 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=465f3d082032824b845e009e38703527487cc5b5;p=python Improve the String tutorial docs (GH-4541) (GH-4546) The paragraph that contains example of string literal concatenation was placed after the section about concatenation using the '+' sign. Moved the paragraph to the appropriate section. (cherry picked from commit 78a5722ae950b80a4b3d13377957f3932195aef3) --- diff --git a/Doc/tutorial/introduction.rst b/Doc/tutorial/introduction.rst index b7be00ed7a..be9aa83474 100644 --- a/Doc/tutorial/introduction.rst +++ b/Doc/tutorial/introduction.rst @@ -218,6 +218,13 @@ to each other are automatically concatenated. :: >>> 'Py' 'thon' 'Python' +This feature is particularly useful when you want to break long strings:: + + >>> text = ('Put several strings within parentheses ' + ... 'to have them joined together.') + >>> text + 'Put several strings within parentheses to have them joined together.' + This only works with two literals though, not with variables or expressions:: >>> prefix = 'Py' @@ -233,13 +240,6 @@ If you want to concatenate variables or a variable and a literal, use ``+``:: >>> prefix + 'thon' 'Python' -This feature is particularly useful when you want to break long strings:: - - >>> text = ('Put several strings within parentheses ' - ... 'to have them joined together.') - >>> text - 'Put several strings within parentheses to have them joined together.' - Strings can be *indexed* (subscripted), with the first character having index 0. There is no separate character type; a character is simply a string of size one::