# Omission in the documentation

**URL:** <https://discuss.python.org/t/omission-in-the-documentation/66816>\
**Category:** Documentation\
**Created:** [October 6, 2024, 7:15am UTC](https://discuss.python.org/t/omission-in-the-documentation/66816 "2024-10-06T07:15:56Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![SALAMANDRA69](https://sea2.discourse-cdn.com/flex002/user_avatar/discuss.python.org/salamandra69/32/22980_2.png) [@SALAMANDRA69](https://discuss.python.org/u/SALAMANDRA69)\
**Post date:** [October 6, 2024, 7:15am UTC](https://discuss.python.org/t/omission-in-the-documentation/66816/1 "2024-10-06T07:15:56Z")

</div>

In section 3.1.2. ‘Text’ of the documentation there is the following example([3. An Informal Introduction to Python — Python 3.12.7 documentation](https://docs.python.org/3/tutorial/introduction.html#:~:text=The%20following%20example%3A)):

```python
print("""\
Usage: thingy [OPTIONS]
     -h Display this usage message
     -H hostname Hostname to connect to
""")

```

it will give the following result:

```python
Usage: thingy [OPTIONS]
     -h Display this usage message
     -H hostname Hostname to connect to

```

I think this example is incorrect because the ‘\’ character is missing at the end of the line on line 4.

```python
print("""\
Usage: thingy [OPTIONS]
     -h Display this usage message
     -H hostname Hostname to connect to\
""")

```

---

<div class="post-metadata">

**Author:** ![Rosuav](https://sea2.discourse-cdn.com/flex002/user_avatar/discuss.python.org/rosuav/32/3429_2.png) [@Rosuav](https://discuss.python.org/u/Rosuav)\
**Post date:** [October 6, 2024, 7:35am UTC](https://discuss.python.org/t/omission-in-the-documentation/66816/2 "2024-10-06T07:35:15Z")

</div>

The only difference would be an additional newline at the end of what’s printed out (since `print()` adds a newline). In the context it’s being used in, this wouldn’t make a difference.

---

<div class="post-metadata">

**Author:** ![SALAMANDRA69](https://sea2.discourse-cdn.com/flex002/user_avatar/discuss.python.org/salamandra69/32/22980_2.png) [@SALAMANDRA69](https://discuss.python.org/u/SALAMANDRA69)\
**Post date:** [October 6, 2024, 7:45am UTC](https://discuss.python.org/t/omission-in-the-documentation/66816/4 "2024-10-06T07:45:13Z")

</div>

Even if you use a newline, you will still have one empty line.

```python
print("""\
Usage: thingy [OPTIONS]
     -h Display this usage message
     -H hostname Hostname to connect to
""", end='')

```

there will be the following conclusion:

```python
Usage: thingy [OPTIONS]
     -h Display this usage message
     -H hostname Hostname to connect to

```

---

<div class="post-metadata">

**Author:** ![saaketp](https://sea2.discourse-cdn.com/flex002/user_avatar/discuss.python.org/saaketp/32/6703_2.png) [@saaketp](https://discuss.python.org/u/saaketp)\
**Post date:** [October 6, 2024, 8:21am UTC](https://discuss.python.org/t/omission-in-the-documentation/66816/5 "2024-10-06T08:21:54Z")

</div>

The example doesn’t say anything about the final newline, it explicitly notes that only the initial newline is not included in the output.

So the correct fix might be to just add a newline at the end of the output.

---

<div class="post-metadata">

**Author:** ![Nineteendo](https://sea2.discourse-cdn.com/flex002/user_avatar/discuss.python.org/nineteendo/32/19122_2.png) [@Nineteendo](https://discuss.python.org/u/Nineteendo)\
**Post date:** [October 6, 2024, 3:50pm UTC](https://discuss.python.org/t/omission-in-the-documentation/66816/6 "2024-10-06T15:50:37Z")

</div>

I don’t think it’s possible to add a trailing newline to a code block:

```rst
.. code-block:: text

   Usage: thingy [OPTIONS]
        -h Display this usage message
        -H hostname Hostname to connect to

```

---

<div class="post-metadata">

**Author:** ![nedbat](https://sea2.discourse-cdn.com/flex002/user_avatar/discuss.python.org/nedbat/32/8744_2.png) [@nedbat](https://discuss.python.org/u/nedbat)\
**Post date:** [October 6, 2024, 10:02pm UTC](https://discuss.python.org/t/omission-in-the-documentation/66816/7 "2024-10-06T22:02:22Z")

</div>

I don’t expect the docs to be exactly precise with regard to final newlines or blank lines. They will not stand out visually and most readers wouldn’t notice them if they were there or not. The doc page in question is fine as it is.

---

<div class="post-metadata">

**Author:** ![MegaIng](https://sea2.discourse-cdn.com/flex002/user_avatar/discuss.python.org/megaing/32/16162_2.png) [@MegaIng](https://discuss.python.org/u/MegaIng)\
**Post date:** [October 7, 2024, 2:56pm UTC](https://discuss.python.org/t/omission-in-the-documentation/66816/8 "2024-10-07T14:56:44Z")

</div>

While this is true most of the time, this code is supposed to show of newline handling, and should therefore IMO be exact. If this is not possible, it should be removed entirely to prevent confusion.

---

<div class="post-metadata">

**Author:** ![jamestwebber](https://sea2.discourse-cdn.com/flex002/user_avatar/discuss.python.org/jamestwebber/32/12799_2.png) [@jamestwebber](https://discuss.python.org/u/jamestwebber)\
**Post date:** [October 7, 2024, 3:04pm UTC](https://discuss.python.org/t/omission-in-the-documentation/66816/9 "2024-10-07T15:04:09Z")

</div>

One option is to put the example in the context of the REPL, like the example after it.

> [@](#):
>
> String literals can span multiple lines. One way is using triple-quotes: “”“…”“” or ‘’‘…’‘’. End of lines are automatically included in the string, but it’s possible to prevent this by adding a \ at the end of the line. In the following example, the initial newline is not included:
> 
> ```python
> >>> print("""\
> ... Usage: thingy [OPTIONS]
> ... -h Display this usage message
> ... -H hostname Hostname to connect to
> """)
> Usage: thingy [OPTIONS]
> -h Display this usage message
> -H hostname Hostname to connect to
> 
> >>>
> 
> ```

This shows exactly what a user would see in the REPL, which is hopefully clearer.

---

<div class="post-metadata">

**Author:** ![SALAMANDRA69](https://sea2.discourse-cdn.com/flex002/user_avatar/discuss.python.org/salamandra69/32/22980_2.png) [@SALAMANDRA69](https://discuss.python.org/u/SALAMANDRA69)\
**Post date:** [October 7, 2024, 5:29pm UTC](https://discuss.python.org/t/omission-in-the-documentation/66816/10 "2024-10-07T17:29:35Z")

</div>

That’s what I mean. An empty line could be included in the example to show the reader exactly how a multiline quote works.

---

<div class="post-metadata">

**Author:** ![nedbat](https://sea2.discourse-cdn.com/flex002/user_avatar/discuss.python.org/nedbat/32/8744_2.png) [@nedbat](https://discuss.python.org/u/nedbat)\
**Post date:** [October 7, 2024, 8:58pm UTC](https://discuss.python.org/t/omission-in-the-documentation/66816/11 "2024-10-07T20:58:14Z")

</div>

A pull request: [Docs: make a tutorial example more precise by nedbat · Pull Request #125066 · python/cpython · GitHub](https://github.com/python/cpython/pull/125066)
