A bit belated, but you have to use setlocale method from the locale module first, I think.
As per the docs:
According to POSIX, a program which has not called setlocale(LC_ALL,
"") runs using the portable 'C' locale. Calling setlocale(LC_ALL, "")
lets it use the default locale as defined by the LANG variable.
Assuming Python 3:
import locale
def get_locale_settings(locale_name: str = "", only_fields: tuple = ("decimal_point", "thousands_sep")) -> dict:
"""Return a dict of locale params.
:param str locale_name: Desired locale name, or empty string for OS default locale.
:param tuple only_fields: Desired locale fields, or None for all fields.
>>>get_locale_settings(locale_name="en_US.utf8", only_fields=("decimal_point", "thousands_sep"))
{'decimal_point': '.', 'thousands_sep': ','}
"""
locale.setlocale(locale.LC_ALL, locale_name)
settings = locale.localeconv()
if settings:
if only_fields:
settings = {field: value for field, value in settings.items() if field in only_fields}
return settings
print(get_locale_settings())
{'decimal_point': ',', 'thousands_sep': '\xa0'}
You can also get all the settings for any desired locale with only_fields=None, say,
get_locale_settings(locale_name="ru_RU.utf8", only_fields=None)
{'int_curr_symbol': 'RUB',
'currency_symbol': '₽',
'mon_decimal_point': ',',
'mon_thousands_sep': '\xa0',
'mon_grouping': [3, 0],
'positive_sign': '',
'negative_sign': '-',
'int_frac_digits': 2,
'frac_digits': 2,
'p_cs_precedes': 0,
'p_sep_by_space': 1,
'n_cs_precedes': 0,
'n_sep_by_space': 1,
'p_sign_posn': 1,
'n_sign_posn': 1,
'decimal_point': ',',
'thousands_sep': '\xa0',
'grouping': [3, 0]}
If you need separators to format a number, it might be easier to just use f-string formatting from this answer.