Date, Time and Localization Modules

locale

Provides locale-sensitive formatting, collation and numeric conversion. Available locale names vary by operating system. setlocale() changes process-wide locale state and is generally not safe to use concurrently; prefer explicit formatting or dedicated locale tools when multiple locales must coexist. The example queries state without changing it.

Formal Syntax & Structure

python syntaxpython
import locale

Return Value

module

Module namespace available through import; import is a statement, not a value-returning expression.

Working Example

Example Snippetpython
import localeprint(isinstance(locale.setlocale(locale.LC_NUMERIC), str))print(isinstance(locale.localeconv()["decimal_point"], str))
Python Reference