From b02c29200fddb7f68415badd4c87da07ced032d8 Mon Sep 17 00:00:00 2001 From: Adorilson Bezerra Date: Tue, 17 Sep 2019 19:38:49 -0300 Subject: [PATCH 1/3] Doc: just add a . in inputoutput tutorial --- Doc/tutorial/inputoutput.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Doc/tutorial/inputoutput.rst b/Doc/tutorial/inputoutput.rst index a404f4be19f1b9..6cff16c0d2d39f 100644 --- a/Doc/tutorial/inputoutput.rst +++ b/Doc/tutorial/inputoutput.rst @@ -172,7 +172,7 @@ Positional and keyword arguments can be arbitrarily combined:: If you have a really long format string that you don't want to split up, it would be nice if you could reference the variables to be formatted by name instead of by position. This can be done by simply passing the dict and using -square brackets ``'[]'`` to access the keys :: +square brackets ``'[]'`` to access the keys. :: >>> table = {'Sjoerd': 4127, 'Jack': 4098, 'Dcab': 8637678} >>> print('Jack: {0[Jack]:d}; Sjoerd: {0[Sjoerd]:d}; ' From 2b03f5e00bf5ff7b1b9cff4cd83510fddcb47101 Mon Sep 17 00:00:00 2001 From: Adorilson Bezerra Date: Tue, 17 Sep 2019 20:27:05 -0300 Subject: [PATCH 2/3] Make clear that sprintf is a C function --- Doc/tutorial/inputoutput.rst | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Doc/tutorial/inputoutput.rst b/Doc/tutorial/inputoutput.rst index 6cff16c0d2d39f..7b5f7e6b14a0b6 100644 --- a/Doc/tutorial/inputoutput.rst +++ b/Doc/tutorial/inputoutput.rst @@ -258,9 +258,9 @@ Old string formatting --------------------- The ``%`` operator can also be used for string formatting. It interprets the -left argument much like a :c:func:`sprintf`\ -style format string to be applied -to the right argument, and returns the string resulting from this formatting -operation. For example:: +left argument much like to C's :c:func:`sprintf`\ -style format string to be +applied to the right argument, and returns the string resulting from this +formatting operation. For example:: >>> import math >>> print('The value of pi is approximately %5.3f.' % math.pi) From b0dd895218dc9c5a9eedddfcd89bb8ec695be18c Mon Sep 17 00:00:00 2001 From: Adorilson Bezerra Date: Wed, 25 Sep 2019 22:04:13 -0300 Subject: [PATCH 3/3] Doc: removed the sprintf mention in inputoutput tutorial --- Doc/tutorial/inputoutput.rst | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Doc/tutorial/inputoutput.rst b/Doc/tutorial/inputoutput.rst index 7b5f7e6b14a0b6..366a532e817afa 100644 --- a/Doc/tutorial/inputoutput.rst +++ b/Doc/tutorial/inputoutput.rst @@ -257,10 +257,10 @@ left with zeros. It understands about plus and minus signs:: Old string formatting --------------------- -The ``%`` operator can also be used for string formatting. It interprets the -left argument much like to C's :c:func:`sprintf`\ -style format string to be -applied to the right argument, and returns the string resulting from this -formatting operation. For example:: +The % operator (modulo) can also be used for string formatting. Given ``'string' +% values``, instances of ``%`` in ``string`` are replaced with zero or more +elements of ``values``. This operation is commonly known as string +interpolation. For example:: >>> import math >>> print('The value of pi is approximately %5.3f.' % math.pi)