8000 gh-134887: Add references to `locale` module for locale-aware number formatting references in `string` module docs by stefmolin · Pull Request #134888 · python/cpython · GitHub
[go: up one dir, main page]

Skip to content

gh-134887: Add references to locale module for locale-aware number formatting references in string module docs #134888

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

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Changes from 1 commit
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
12 changes: 8 additions & 4 deletions Doc/library/string.rst
Original file line number Diff line number Diff line change
Expand Up @@ -469,7 +469,9 @@ of a number respectively. It can be one of the following:
| | this option is not supported. |
+---------+----------------------------------------------------------+

For a locale aware separator, use the ``'n'`` presentation type instead.
For a locale-aware separator, use the ``'n'`` presentation type instead. Note
that the locale setting for numeric values must first be set using the
:mod:`locale` module, *e.g.,* ``locale.setlocale(locale.LC_NUMERIC, 'en_US')``.
Copy link
Member

Choose a reason for hiding this comment

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

Copy link
Author
@stefmolin stefmolin May 29, 2025

Choose a reason for hiding this comment

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

There are two other occurrences of "e.g." in this document that pre-date my changes. Would you like me to update those as well?


.. versionchanged:: 3.1
Added the ``','`` option (see also :pep:`378`).
Expand Down Expand Up @@ -517,7 +519,8 @@ The available integer presentation types are:
+---------+----------------------------------------------------------+
| ``'n'`` | Number. This is the same as ``'d'``, except that it uses |
| | the current locale setting to insert the appropriate |
| | digit group separators. |
| | digit group separators, provided that the locale has |
| | been properly set (see the :mod:`locale` module). |
+---------+----------------------------------------------------------+
| None | The same as ``'d'``. |
+---------+----------------------------------------------------------+
Expand Down Expand Up @@ -599,8 +602,9 @@ The available presentation types for :class:`float` and
+---------+----------------------------------------------------------+
| ``'n'`` | Number. This is the same as ``'g'``, except that it uses |
| | the current locale setting to insert the appropriate |
| | digit group separators |
| | for the integral part of a number. |
| | digit group separators for the integral part of a |
| | number, provided that the locale has been properly set |
| | (see the :mod:`locale` module). |
+---------+----------------------------------------------------------+
| ``'%'`` | Percentage. Multiplies the number by 100 and displays |
| | in fixed (``'f'``) format, followed by a percent sign. |
Expand Down
Loading
0