[Python-checkins] cpython (3.5): Update example; str(float) changed so there is difference now.

georg.brandl python-checkins at python.org
Mon Feb 22 08:53:14 EST 2016


https://hg.python.org/cpython/rev/6b502158acc8
changeset:   100300:6b502158acc8
branch:      3.5
parent:      100298:82afdf5a8c7b
user:        Georg Brandl <georg at python.org>
date:        Mon Feb 22 14:52:55 2016 +0100
summary:
  Update example; str(float) changed so there is difference now.

files:
  Doc/tutorial/inputoutput.rst |  10 +++++-----
  1 files changed, 5 insertions(+), 5 deletions(-)


diff --git a/Doc/tutorial/inputoutput.rst b/Doc/tutorial/inputoutput.rst
--- a/Doc/tutorial/inputoutput.rst
+++ b/Doc/tutorial/inputoutput.rst
@@ -152,11 +152,11 @@
 ``'!a'`` (apply :func:`ascii`), ``'!s'`` (apply :func:`str`) and ``'!r'``
 (apply :func:`repr`) can be used to convert the value before it is formatted::
 
-   >>> import math
-   >>> print('The value of PI is approximately {}.'.format(math.pi))
-   The value of PI is approximately 3.14159265359.
-   >>> print('The value of PI is approximately {!r}.'.format(math.pi))
-   The value of PI is approximately 3.141592653589793.
+   >>> contents = 'eels'
+   >>> print('My hovercraft is full of {}.'.format(contents))
+   My hovercraft is full of eels.
+   >>> print('My hovercraft is full of {!r}.'.format(contents))
+   My hovercraft is full of 'eels'.
 
 An optional ``':'`` and format specifier can follow the field name. This allows
 greater control over how the value is formatted.  The following example

-- 
Repository URL: https://hg.python.org/cpython


More information about the Python-checkins mailing list