Skip to content

Commit 6e3c70c

Browse files
authored
Docs: make a tutorial example more precise (#125066)
Based on discussion here: https://discuss.python.org/t/omission-in-the-documentation/66816
1 parent 447a151 commit 6e3c70c

File tree

1 file changed

+9
-11
lines changed

1 file changed

+9
-11
lines changed

Doc/tutorial/introduction.rst

+9-11
Original file line numberDiff line numberDiff line change
@@ -197,21 +197,19 @@ and workarounds.
197197
String literals can span multiple lines. One way is using triple-quotes:
198198
``"""..."""`` or ``'''...'''``. End of lines are automatically
199199
included in the string, but it's possible to prevent this by adding a ``\`` at
200-
the end of the line. The following example::
201-
202-
print("""\
200+
the end of the line. In the following example, the initial newline is not
201+
included::
202+
203+
>>> print("""\
204+
... Usage: thingy [OPTIONS]
205+
... -h Display this usage message
206+
... -H hostname Hostname to connect to
207+
... """)
203208
Usage: thingy [OPTIONS]
204209
-h Display this usage message
205210
-H hostname Hostname to connect to
206-
""")
207-
208-
produces the following output (note that the initial newline is not included):
209211

210-
.. code-block:: text
211-
212-
Usage: thingy [OPTIONS]
213-
-h Display this usage message
214-
-H hostname Hostname to connect to
212+
>>>
215213

216214
Strings can be concatenated (glued together) with the ``+`` operator, and
217215
repeated with ``*``::

0 commit comments

Comments
 (0)