Skip to content

Commit 4e24a3f

Browse files
committed
Adding documentation inside what's new in 3.7
Fixed recommended CR changes
1 parent a08419f commit 4e24a3f

File tree

3 files changed

+14
-5
lines changed

3 files changed

+14
-5
lines changed

Doc/library/locale.rst

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -371,12 +371,19 @@ The :mod:`locale` module defines the following exception and functions:
371371

372372
.. function:: format_string(format, val, grouping=False, monetary=False)
373373

374+
Formats a number *val* according to the current :const:`LC_NUMERIC` setting.
375+
The format follows the conventions of the ``%`` operator. For floating point
376+
values, the decimal point is modified if appropriate. If *grouping* is true,
377+
also takes the grouping into account.
378+
379+
If *monetary* is true, the conversion uses monetary thousands separator and
380+
grouping strings.
381+
374382
Processes formatting specifiers as in ``format % val``, but takes the current
375383
locale settings into account.
376384

377385
.. versionchanged:: 3.7
378386
The *monetary* keyword parameter was added.
379-
Replaces :meth:`format`.
380387

381388

382389
.. function:: currency(val, symbol=True, grouping=False, international=False)

Doc/whatsnew/3.7.rst

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,11 @@ API and Feature Removals
158158
Python 3.1, and has now been removed. Use the :func:`~os.path.splitdrive`
159159
function instead.
160160

161+
* Deprecated :meth:`format` from :mod:`locale`, use the :meth:`format_string`
162+
instead. Added another argument *monetary* in :meth:`format_string` of
163+
:mod:`locale`.
164+
(Contributed by Garvit in :issue:`10379`.)
165+
161166

162167
Porting to Python 3.7
163168
=====================

Lib/test/test_locale.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -199,11 +199,8 @@ def test_padding(self):
199199
self._test_format("%-10.f", 4200, grouping=0, out='4200'.ljust(10))
200200

201201
def test_format_deprecation(self):
202-
with warnings.catch_warnings(record=True) as w:
203-
warnings.simplefilter("always", DeprecationWarning)
202+
with self.assertWarns(DeprecationWarning):
204203
locale.format("%-10.f", 4200, grouping=True)
205-
for warning in w:
206-
self.assertTrue(warning.category is DeprecationWarning)
207204

208205
def test_complex_formatting(self):
209206
# Spaces in formatting string

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy