Qucs-S S-parameter Viewer & RF Synthesis Tools
Loading...
Searching...
No Matches
Functions | Variables
babel.lists Namespace Reference

Functions

 __getattr__ (name)
 
str format_list (Sequence[str] lst, Literal['standard', 'standard-short', 'or', 'or-short', 'unit', 'unit-short', 'unit-narrow'] style='standard', Locale|str|None locale=None)
 
 _resolve_list_style (Locale locale, str style)
 

Variables

 _DEFAULT_LOCALE = default_locale()
 
dict _style_fallbacks
 

Detailed Description

    babel.lists
    ~~~~~~~~~~~

    Locale dependent formatting of lists.

    The default locale for the functions in this module is determined by the
    following environment variables, in that order:

     * ``LC_ALL``, and
     * ``LANG``

    :copyright: (c) 2015-2025 by the Babel Team.
    :license: BSD, see LICENSE for more details.

Function Documentation

◆ format_list()

str babel.lists.format_list ( Sequence[str]  lst,
Literal['standard', 'standard-short', 'or', 'or-short', 'unit', 'unit-short', 'unit-narrow']   style = 'standard',
Locale | str | None   locale = None 
)
Format the items in `lst` as a list.

>>> format_list(['apples', 'oranges', 'pears'], locale='en')
u'apples, oranges, and pears'
>>> format_list(['apples', 'oranges', 'pears'], locale='zh')
u'apples\u3001oranges\u548cpears'
>>> format_list(['omena', 'peruna', 'aplari'], style='or', locale='fi')
u'omena, peruna tai aplari'

Not all styles are necessarily available in all locales.
The function will attempt to fall back to replacement styles according to the rules
set forth in the CLDR root XML file, and raise a ValueError if no suitable replacement
can be found.

The following text is verbatim from the Unicode TR35-49 spec [1].

* standard:
  A typical 'and' list for arbitrary placeholders.
  eg. "January, February, and March"
* standard-short:
  A short version of an 'and' list, suitable for use with short or abbreviated placeholder values.
  eg. "Jan., Feb., and Mar."
* or:
  A typical 'or' list for arbitrary placeholders.
  eg. "January, February, or March"
* or-short:
  A short version of an 'or' list.
  eg. "Jan., Feb., or Mar."
* unit:
  A list suitable for wide units.
  eg. "3 feet, 7 inches"
* unit-short:
  A list suitable for short units
  eg. "3 ft, 7 in"
* unit-narrow:
  A list suitable for narrow units, where space on the screen is very limited.
  eg. "3′ 7″"

[1]: https://www.unicode.org/reports/tr35/tr35-49/tr35-general.html#ListPatterns

:param lst: a sequence of items to format in to a list
:param style: the style to format the list with. See above for description.
:param locale: the locale. Defaults to the system locale.

Variable Documentation

◆ _style_fallbacks

dict babel.lists._style_fallbacks
protected
Initial value:
1= {
2 "or-narrow": ["or-short", "or"],
3 "or-short": ["or"],
4 "standard-narrow": ["standard-short", "standard"],
5 "standard-short": ["standard"],
6 "unit": ["unit-short", "standard"],
7 "unit-narrow": ["unit-short", "unit", "standard"],
8 "unit-short": ["standard"],
9}