class documentation

class NumberPattern(object):

View In Hierarchy

Undocumented

Method __init__ Undocumented
Method __repr__ Undocumented
Method ​_format​_frac Undocumented
Method ​_format​_int Undocumented
Method ​_format​_significant Undocumented
Method ​_quantize​_value Undocumented
Method apply Renders into a string a number following the defined pattern.
Method compute​_scale Return the scaling factor to apply to the number before rendering.
Method scientific​_notation​_elements Returns normalized scientific notation components of a value.
Instance Variable exp​_plus Undocumented
Instance Variable exp​_prec Undocumented
Instance Variable frac​_prec Undocumented
Instance Variable grouping Undocumented
Instance Variable int​_prec Undocumented
Instance Variable pattern Undocumented
Instance Variable prefix Undocumented
Instance Variable scale Undocumented
Instance Variable suffix Undocumented
def __init__(self, pattern, prefix, suffix, grouping, int_prec, frac_prec, exp_prec, exp_plus):

Undocumented

def __repr__(self):

Undocumented

def _format_frac(self, value, locale, force_frac=None):

Undocumented

def _format_int(self, value, min, max, locale):

Undocumented

def _format_significant(self, value, minimum, maximum):

Undocumented

def _quantize_value(self, value, locale, frac_prec, group_separator):

Undocumented

def apply(self, value, locale, currency=None, currency_digits=True, decimal_quantization=True, force_frac=None, group_separator=True):

Renders into a string a number following the defined pattern.

Forced decimal quantization is active by default so we'll produce a number string that is strictly following CLDR pattern definitions.

Parameters
value:decimal.Decimal|float|intThe value to format. If this is not a Decimal object, it will be cast to one.
locale:str|babel.core.LocaleThe locale to use for formatting.
currency:str|NoneWhich currency, if any, to format as.
currency​_digits:boolWhether or not to use the currency's precision. If false, the pattern's precision is used.
decimal​_quantization:boolWhether decimal numbers should be forcibly quantized to produce a formatted output strictly matching the CLDR definition for the locale.
force​_fracDEPRECATED - a forced override for self.frac_prec for a single formatting invocation.
group​_separatorUndocumented
Returns
strFormatted decimal string.
def compute_scale(self):

Return the scaling factor to apply to the number before rendering.

Auto-set to a factor of 2 or 3 if presence of a % or sign is detected in the prefix or suffix of the pattern. Default is to not mess with the scale at all and keep it to 0.

def scientific_notation_elements(self, value, locale):
Returns normalized scientific notation components of a value.
exp_plus =

Undocumented

exp_prec =

Undocumented

frac_prec =

Undocumented

grouping =

Undocumented

int_prec =

Undocumented

pattern =

Undocumented

prefix =

Undocumented

scale =

Undocumented

suffix =

Undocumented