You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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:
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:
Documentation
I was trying out the option of using
nin a format specifier to use locale-aware thousands and decimal separators. I was surprised to see it didn't do anything on my machine, despitelocale.getlocale()returning what I expected: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 thenoption:I propose adding a mention that the
locale.LC_NUMERICmust be set in this section as a helpful cross-reference.Linked PRs
localemodule for locale-aware number formatting references instringmodule docs #134888localemodule for locale-aware number formatting references instringmodule docs (GH-134888) #150120localemodule for locale-aware number formatting references instringmodule docs (GH-134888) #150121localemodule for locale-aware number formatting references instringmodule docs (GH-134888) #150122