| .. data:: ALT_DIGITS |
| |
| The return value is a representation of up to 100 values used to represent the |
| values 0 to 99. |
| |
| Example:: |
| |
| >>> import locale |
n | >>> loc = locale.getlocale(locale.LC_ALL) # get current locale |
n | >>> loc = locale.getlocale() # get current locale |
| >>> locale.setlocale(locale.LC_ALL, 'de_DE') # use German locale; name might vary with platform |
n | >>> locale.strcoll('f\xe4n', 'foo') # compare a string containing an umlaut |
n | >>> locale.strcoll('f\xe4n', 'foo') # compare a string containing an umlaut |
| >>> locale.setlocale(locale.LC_ALL, '') # use user's preferred locale |
| >>> locale.setlocale(locale.LC_ALL, 'C') # use default (C) locale |
| >>> locale.setlocale(locale.LC_ALL, loc) # restore saved locale |
| |
| |
| Background, details, hints, tips and caveats |
| -------------------------------------------- |
| |
| yourself that using locale settings is okay. Only as a last resort should you |
| document that your module is not compatible with non-\ ``C`` locale settings. |
| |
| .. index:: module: string |
| |
| The case conversion functions in the :mod:`string` module are affected by the |
| locale settings. When a call to the :func:`setlocale` function changes the |
| :const:`LC_CTYPE` settings, the variables ``string.lowercase``, |
t | ``string.uppercase`` and ``string.letters`` are recalculated. Note that this |
t | ``string.uppercase`` and ``string.letters`` are recalculated. Note that code |
| code that uses these variable through ':keyword:`from` ... :keyword:`import` |
| that uses these variable through ':keyword:`from` ... :keyword:`import` ...', |
| ...', e.g. ``from string import letters``, is not affected by subsequent |
| e.g. ``from string import letters``, is not affected by subsequent |
| :func:`setlocale` calls. |
| |
| The only way to perform numeric operations according to the locale is to use the |
| special functions defined by this module: :func:`atof`, :func:`atoi`, |
| :func:`format`, :func:`str`. |
| |
| |
| .. _embedding-locale: |