Skip to content

Doc: inputoutput tutorial improvements #16251

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
May 28, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions Doc/tutorial/inputoutput.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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. ::
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Within this context, the sentence is correct with or without the period since it's referring to an example, but I think your change is okay.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

More or less. Periods before an example always ends with a "." or with a ":". Right?
I chose the first one for no special reason.

Copy link
Contributor

@aeros aeros Sep 20, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@adorilson:

More or less. Periods before an example always ends with a "." or with a ":". Right?

Here are all of the correct ways to use examples within the Python docs (as far as I'm aware):

This can be done by simply passing the dict and using square brackets ``'[]'``
to access the keys::
This can be done by simply passing the dict and using square brackets ``'[]'``
to access the keys. For example::
This can be done by simply passing the dict and using square brackets ``'[]'``
to access the keys. ::

Those types of formatting corrections aren't worth their own PR, but it can be useful to touch up on them if you're working on a nearby area for something more significant (such as with this PR). The quote used in PEP 8, "A foolish consistency is the hobgoblin of little minds", would be applicable to changing a section exclusively to use the correct formatting conventions.


>>> table = {'Sjoerd': 4127, 'Jack': 4098, 'Dcab': 8637678}
>>> print('Jack: {0[Jack]:d}; Sjoerd: {0[Sjoerd]:d}; '
Expand Down Expand Up @@ -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 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::
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)
Expand Down