Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
str() with float an i18n
#2
here's the doc on that: https://docs.python.org/3.7/library/loca...LC_NUMERIC
Quote:locale.setlocale(category, locale=None)

If locale is given and not None, setlocale() modifies the locale setting for the category. The available categories are listed in the data description below. locale may be a string, or an iterable of two strings (language code and encoding). If it’s an iterable, it’s converted to a locale name using the locale aliasing engine. An empty string specifies the user’s default settings. If the modification of the locale fails, the exception Error is raised. If successful, the new locale setting is returned.

If locale is omitted or None, the current setting for category is returned.

setlocale() is not thread-safe on most systems. Applications typically start with a call of

import locale
locale.setlocale(locale.LC_ALL, '')

This sets the locale for all categories to the user’s default setting (typically specified in the LANG environment variable). If the locale is not changed thereafter, using multithreading should not cause problems.
I haven't actually tried it, but looks like it will accommodate numbers using LC_NUMERIC
'locale.localeconv()' Returns the database of the local conventions as a dictionary.
Leave testing to you.
Reply


Messages In This Thread
str() with float an i18n - by Skaperen - Dec-24-2018, 06:23 PM
RE: str() with float an i18n - by Larz60+ - Dec-25-2018, 10:51 AM
RE: str() with float an i18n - by Skaperen - Dec-25-2018, 06:30 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  python calculate float plus float is incorrect? sirocawa 6 389 Apr-16-2024, 01:45 PM
Last Post: DeaD_EyE
  Comaparing Float Values of Dictionary Against A Float Value & Pick Matching Key firebird 2 3,428 Jul-25-2019, 11:32 PM
Last Post: scidam

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020