FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

gh-142108: document conversion rules for printf-style formatting by skirpichev · Pull Request #142126 · python/cpython · GitHub

Repository navigation

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension .rst  (2) All 1 file type selected
Viewed files
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Unified
Split
Hide whitespace
Diff view
Unified
Split
Hide whitespace
6 changes: 6 additions & 0 deletions Doc/library/stdtypes.rst
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -3218,6 +3218,12 @@ The conversion types are:
| | character in the result. | |
+------------+-----------------------------------------------------+-------+

For a general non-string Python object ``obj``, numeric conversion types
attempt to format values, converted first to built-in :class:`float` (by
``float(obj)``, for floating-point formats) and :class:`int` (by
``operator.index(obj)`` for ``'o'``, ``'x'``, ``'X'`` or ``'c'`` formats, or by
``int(obj)`` for other integer formats) types.

For floating-point formats, the result should be correctly rounded to a given
precision ``p`` of digits after the decimal point. The rounding mode matches
that of the :func:`round` builtin.
Expand Down
2 changes: 1 addition & 1 deletion Doc/library/string.rst
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -660,7 +660,7 @@ Format examples
^^^^^^^^^^^^^^^

This section contains examples of the :meth:`str.format` syntax and
comparison with the old ``%``-formatting.
comparison with the old :ref:`printf-style formatting <old-string-formatting>`.

In most of the cases the syntax is similar to the old ``%``-formatting, with the
addition of the ``{}`` and with ``:`` used instead of ``%``.
Expand Down
Loading

Back | FazBrowse Home | New Git URL