[Python-checkins] Improve the String tutorial docs (GH-4541) (GH-4545)
Mariatta
webhook-mailer at python.org
Fri Nov 24 12:35:11 EST 2017
https://github.com/python/cpython/commit/7b909a93bf8dfa4b81d0d6bdb0611418d41d507b
commit: 7b909a93bf8dfa4b81d0d6bdb0611418d41d507b
branch: 3.6
author: Miss Islington (bot) <31488909+miss-islington at users.noreply.github.com>
committer: Mariatta <Mariatta at users.noreply.github.com>
date: 2017-11-24T09:35:08-08:00
summary:
Improve the String tutorial docs (GH-4541) (GH-4545)
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)
files:
M Doc/tutorial/introduction.rst
diff --git a/Doc/tutorial/introduction.rst b/Doc/tutorial/introduction.rst
index 8956aa5a261..6415ae66ab8 100644
--- a/Doc/tutorial/introduction.rst
+++ b/Doc/tutorial/introduction.rst
@@ -212,6 +212,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'
@@ -227,13 +234,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::
More information about the Python-checkins
mailing list