-
-
Notifications
You must be signed in to change notification settings - Fork 33.6k
Open
Labels
docsDocumentation in the Doc dirDocumentation in the Doc dir
Description
Documentation
I was trying out the option of using n in a format specifier to use locale-aware thousands and decimal separators. I was surprised to see it didn't do anything on my machine, despite locale.getlocale() returning what I expected:
>>> import locale
>>> locale.getlocale()
('en_US', 'UTF-8')
>>> x = 12345
>>> f'{x:n}'
'12345'I did some more digging and realized I needed to do locale.setlocale(locale.LC_NUMERIC, 'en_US') first, which was neither obvious nor mentioned in the documentation where it introduces the n option:
>>> import locale
>>> locale.setlocale(locale.LC_NUMERIC, 'en_US')
>>> x = 12345
>>> f'{x:n}'
'12,345'I propose adding a mention that the locale.LC_NUMERIC must be set in this section as a helpful cross-reference.
Linked PRs
Metadata
Metadata
Assignees
Labels
docsDocumentation in the Doc dirDocumentation in the Doc dir
Projects
Status
Todo