def nice_number(number, thousands_separator='<STR_LIT:U+002C>', max_ndigits_after_dot=None):
if isinstance(number, float):<EOL><INDENT>if max_ndigits_after_dot is not None:<EOL><INDENT>number = round(number, max_ndigits_after_dot)<EOL><DEDENT>int_part, frac_part = str(number).split('<STR_LIT:.>')<EOL>return '<STR_LIT>' % (nice_number(int(int_part), thousands_separator),<EOL>frac_part)<EOL><DEDENT>else:<EOL><INDENT>chars_in = list(str(number))<EOL>number = len(chars_in)<EOL>chars_out = []<EOL>for i in range(<NUM_LIT:0>, number):<EOL><INDENT>if i % <NUM_LIT:3> == <NUM_LIT:0> and i != <NUM_LIT:0>:<EOL><INDENT>chars_out.append(thousands_separator)<EOL><DEDENT>chars_out.append(chars_in[number - i - <NUM_LIT:1>])<EOL><DEDENT>chars_out.reverse()<EOL>return '<STR_LIT>'.join(chars_out)<EOL><DEDENT>
Return nicely printed number NUMBER in language LN.

    Return nicely printed number NUMBER in language LN using
    given THOUSANDS_SEPARATOR character.
    If max_ndigits_after_dot is specified and the number is float, the
    number is rounded by taking in consideration up to max_ndigits_after_dot
    digit after the dot.

    This version does not pay attention to locale.  See
    tmpl_nice_number_via_locale().