On this page
  1. locale.getdefaultlocale
  2. Import
  3. Signature & Overview
  4. Usage
  5. Gotchas
  6. REPL Inspect

locale.getdefaultlocale

Prev: locale.format_string | Up: locale | Next: locale.getencoding
Rel: locale.atof, locale.atoi, locale.currency, locale.Error
Ref: docs.python.org — locale.getdefaultlocale
Tags: #public #python3 #stdlib #locale


Import

import locale
from locale import getdefaultlocale

Signature & Overview

locale.getdefaultlocale(envvars=('LC_ALL', 'LC_CTYPE', 'LANG', 'LANGUAGE'))

Tries to determine the default locale settings and returns them as tuple (language code, encoding).

Usage

import locale

# Deprecated (removed in Python 3.15): prefer locale.getlocale() or locale.getencoding()
assert callable(locale.getlocale)

Gotchas

REPL Inspect

from locale import getdefaultlocale
help(getdefaultlocale)

Linked from

Related notes