Module gnue.common.utils.xlocale
Helper functions which we think are missing in python's locale
module.
| Function Summary |
| |
format_numeric(fmt_string,
value,
pattern)
Format a numeric value using a conversion specifier (fmt_string) and
apply grouping (thousands separating, decimal point) according to a given
pattern or as defined by the current locale. |
format_numeric(fmt_string,
value,
pattern=None)
Format a numeric value using a conversion specifier (fmt_string) and
apply grouping (thousands separating, decimal point) according to a
given pattern or as defined by the current locale.
The grouping-pattern used for thousands separating and definition of
the decimal point. The format of this string is
<thousand-separator><number of digits><decimal
separator> where the pair <thousand-separator><number of
digits> can be repeated.
Examples: assume a call of format_numeric('%.2f', 1234567.89, pat)
with
-
pat = ',3.' result is 1,234,567.89
-
pat = ',3.3,' result is 1,234.567,89
-
pat = '#2.1;' result is 1#23.4#56.7;89
In the last example you can see that the grouping pattern will be
repeated as a whole.
-
- Parameters:
fmt_string -
conversion specifier as used by pythons string formatting,
i.e. %.2f or %d
value -
numeric value to be formatted. This value will be converted
using @fmt_string and that result get's
processed according to either the grouping-pattern or the locales
default.
pattern -
the grouping-pattern used for thousands separating and
definition of the decimal point. If no pattern is given (None),
thousands separating and decimal point replacement is done by the
locale.
- Returns:
-
a formatted string according to the given conversion specifier
as well as thousands-separating and decimal point replacement as
defined by the pattern or locale.
|