Did I find the right examples for you? yes no      Crawl my project      Python Jobs

All Samples(117)  |  Call(86)  |  Derive(0)  |  Import(31)

        def format_decimal(number, format=None, locale=LC_NUMERIC):
    u"""Return the given decimal number formatted for a specific locale.

    >>> format_decimal(1.2345, locale='en_US')
    u'1.234'
    >>> format_decimal(1.2346, locale='en_US')
    u'1.235'
    >>> format_decimal(-1.2346, locale='en_US')
    u'-1.235'
    >>> format_decimal(1.2345, locale='sv_SE')
    u'1,234'
    >>> format_decimal(1.2345, locale='de')
    u'1,234'

    The appropriate thousands grouping and the decimal separator are used for
    each locale:

    >>> format_decimal(12345.5, locale='en_US')
    u'12,345.5'

    :param number: the number to format
    :param format:
    :param locale: the `Locale` object or locale identifier
    """
    locale = Locale.parse(locale)
    if not format:
        format = locale.decimal_formats.get(format)
    pattern = parse_pattern(format)
    return pattern.apply(number, locale)
        


src/m/e/mediadrop-HEAD/mediadrop/lib/i18n.py   mediadrop(Download)
from babel.dates import (format_date as _format_date,
    format_datetime as _format_datetime, format_time as _format_time)
from babel.numbers import format_decimal as _format_decimal
from babel.support import Translations
from babel.util import LOCALTZ
    :rtype: `unicode`
    """
    return _format_decimal(number, locale=translator.locale)
 
def format_time(time=None, format='medium', tzinfo=None):

src/p/l/Plurk_Solace-0.1/solace/i18n/__init__.py   Plurk_Solace(Download)
def format_number(number):
    return numbers.format_decimal(number, locale=get_locale())
 
 
def list_languages():

src/p/e/Personal-Website-HEAD/app.py   Personal-Website(Download)
from flask import Flask, render_template, request
from raven.contrib.flask import Sentry
from babel.numbers import format_decimal
from libs.utils import getRSS
 
def number_format(number):
    """Custom Jinja filter for adding a better number display, according
    to the locale
    """
    return format_decimal(number, locale='en_US')

src/s/o/solace-HEAD/solace/i18n/__init__.py   solace(Download)
def format_number(number):
    return numbers.format_decimal(number, locale=get_locale())
 
 
def list_languages():

src/s/k/skylines-HEAD/skylines/lib/formatter/numbers.py   skylines(Download)
def format_decimal(*args, **kw):
    return babel.numbers.format_decimal(*args, locale=get_locale(), **kw)
 

src/f/j/fjord-HEAD/vendor/packages/Babel/tests/test_numbers.py   fjord(Download)
    def test_formatting_of_very_small_decimals(self):
        # previously formatting very small decimals could lead to a type error
        # because the Decimal->string conversion was too simple (see #214)
        number = Decimal("7E-7")
        fmt = numbers.format_decimal(number, format="@@@", locale='en_US')
def test_format_decimal():
    assert numbers.format_decimal(1.2345, locale='en_US') == u'1.234'
    assert numbers.format_decimal(1.2346, locale='en_US') == u'1.235'
    assert numbers.format_decimal(-1.2346, locale='en_US') == u'-1.235'
    assert numbers.format_decimal(1.2345, locale='sv_SE') == u'1,234'

src/z/e/ZenPacks.zenoss.OpenStack-HEAD/src/Babel-1.3/tests/test_numbers.py   ZenPacks.zenoss.OpenStack(Download)
    def test_formatting_of_very_small_decimals(self):
        # previously formatting very small decimals could lead to a type error
        # because the Decimal->string conversion was too simple (see #214)
        number = Decimal("7E-7")
        fmt = numbers.format_decimal(number, format="@@@", locale='en_US')
def test_format_decimal():
    assert numbers.format_decimal(1.2345, locale='en_US') == u'1.234'
    assert numbers.format_decimal(1.2346, locale='en_US') == u'1.235'
    assert numbers.format_decimal(-1.2346, locale='en_US') == u'-1.235'
    assert numbers.format_decimal(1.2345, locale='sv_SE') == u'1,234'

src/b/a/Babel-1.3/tests/test_numbers.py   Babel(Download)
    def test_formatting_of_very_small_decimals(self):
        # previously formatting very small decimals could lead to a type error
        # because the Decimal->string conversion was too simple (see #214)
        number = Decimal("7E-7")
        fmt = numbers.format_decimal(number, format="@@@", locale='en_US')
def test_format_decimal():
    assert numbers.format_decimal(1.2345, locale='en_US') == u'1.234'
    assert numbers.format_decimal(1.2346, locale='en_US') == u'1.235'
    assert numbers.format_decimal(-1.2346, locale='en_US') == u'-1.235'
    assert numbers.format_decimal(1.2345, locale='sv_SE') == u'1,234'

src/a/l/AllSpeak-0.5.1/tests/test_i18n.py   AllSpeak(Download)
from babel import Locale
from babel.dates import format_date, format_datetime, format_time
from babel.numbers import (format_currency, format_decimal, format_number,
    format_percent, format_scientific)
from markupsafe import Markup

Previous  1 | 2 | 3 | 4 | 5 | 6 | 7