Skip to content

Introduction

Cosmo formats money, dates, numbers, units, and text using the conventions of a locale. Set a locale and, for date and time formatting, a time zone, then call the formatter you need.

Cosmo uses ICU for locale data and formatting:

from cosmo import Cosmo

c = Cosmo("es_ES")
c.money(11000.4, "EUR")      # "11.000,40 €"
c.percentage(0.2)            # "20%"

Locale data from ICU

Cosmo reads locale data from ICU rather than maintaining its own tables. The library uses PyICU, which binds ICU's C++ API.

See Platform notes for supported features and limitations.

Next steps