Package pytils :: Module numeral
[show private | hide private]
[frames | no frames]

Module pytils.numeral

Plural forms and in-word representation for numerals.
Function Summary
unicode choose_plural(amount, variants)
Choose proper case depending on amount

unicode

raise TypeError: when amount not int or float
in_words(amount, gender)
Numeral in words
unicode in_words_float(amount, gender)
Float in words
unicode in_words_int(amount, gender)
Integer in words
unicode rubles(amount, zero_for_kopeck)
Get string for money
unicode sum_string(amount, gender, items)
Get sum in words

Function Details

choose_plural(amount, variants)

Choose proper case depending on amount
Parameters:
amount - amount of objects
           (type=int)
variants - variants (forms) of object in such form: (1 object, 2 objects, 5 objects).
           (type=3-element sequence of unicode)
Returns:
proper variant
           (type=unicode)

in_words(amount, gender=None)

Numeral in words
Parameters:
amount - numeral
           (type=int or float)
gender - gender (male=1, female=2, neuter=3)
           (type=int)
Returns:
in-words reprsentation of numeral
           (type=

unicode

raise TypeError: when amount not int or float)

in_words_float(amount, gender=2)

Float in words
Parameters:
amount - float numeral
           (type=float)
gender - gender (male=1, female=2, neuter=3)
           (type=int)
Returns:
in-words reprsentation of float numeral
           (type=unicode)
Raises:
AssertionError - when amount is not float

in_words_int(amount, gender=1)

Integer in words
Parameters:
amount - numeral
           (type=int)
gender - gender (male=1, female=2, neuter=3)
           (type=int)
Returns:
in-words reprsentation of numeral
           (type=unicode)
Raises:
AssertionError - when amount is not int

rubles(amount, zero_for_kopeck=False)

Get string for money
Parameters:
amount - amount of money
           (type=int or float)
zero_for_kopeck - If false, then zero kopecks ignored
           (type=bool)
Returns:
in-words representation of money's amount
           (type=unicode)
Raises:
AssertionError - input parameters' check failed

sum_string(amount, gender, items=None)

Get sum in words
Parameters:
amount - amount of objects
           (type=int)
gender - gender of object (male=1, female=2, neuter=3)
           (type=int)
items - variants of object in three forms: for one object, for two objects and for five objects
           (type=3-element sequence of unicode)
Returns:
in-words representation objects' amount
           (type=unicode)
Raises:
AssertionError - input parameters' check failed

Generated by Epydoc 2.1 on Sat Sep 2 23:16:44 2006 http://epydoc.sf.net