num2words/base.py
def to_currency(self, val, currency='EUR', cents=True, separator=',',
                    adjective=False):
        """
        Args:
            val: Numeric value
            currency (str): Currency code
            cents (bool): Verbose cents
            separator (str): Cent separator
            adjective (bool): Prefix currency name with adjective
        Returns:
            str: Formatted string

        """
        left, right, is_negative = parse_currency_parts(val)

        try:
            cr1, cr2 = self.CURRENCY_FORMS[currency]

        except KeyError:
            raise NotImplementedError(
                'Currency code "%s" not implemented for "%s"' %
                (currency, self.__class__.__name__))

        if adjective and currency in self.CURRENCY_ADJECTIVES:
            cr1 = prefix_currency(self.CURRENCY_ADJECTIVES[currency], cr1)

        minus_str = "%s " % self.negword if is_negative else ""
        cents_str = self._cents_verbose(right, currency) \
            if cents else self._cents_terse(right, currency)

        return u'%s%s %s%s %s %s' % (
            minus_str,
            self.to_cardinal(left),
            self.pluralize(left, cr1),
            separator,
            cents_str,
            self.pluralize(right, cr2)
        )
def to_currency(self, val, currency='EUR', cents=True, separator=',',
                    adjective=False):
        """
        Args:
            val: Numeric value
            currency (str): Currency code
            cents (bool): Verbose cents
            separator (str): Cent separator
            adjective (bool): Prefix currency name with adjective
        Returns:
            str: Formatted string

        """
        left, right, is_negative = parse_currency_parts(val)

        try:
            cr1, cr2 = self.CURRENCY_FORMS[currency]

        except KeyError:
            raise NotImplementedError(
                'Currency code "%s" not implemented for "%s"' %
                (currency, self.__class__.__name__))

        if adjective and currency in self.CURRENCY_ADJECTIVES:
            cr1 = prefix_currency(self.CURRENCY_ADJECTIVES[currency], cr1)

        minus_str = "%s " % self.negword if is_negative else ""
        cents_str = self._cents_verbose(right, currency) \
            if cents else self._cents_terse(right, currency)

        return u'%s%s %s%s %s %s' % (
            minus_str,
            self.to_cardinal(left),
            self.pluralize(left, cr1),
            separator,
            cents_str,
            self.pluralize(right, cr2)
        )
def to_currency ( self , val , currency = 'EUR' , cents = True , separator = ',' , adjective = False ) : left , right , is_negative = parse_currency_parts ( val ) try : cr1 , cr2 = self . CURRENCY_FORMS [ currency ] except KeyError : raise NotImplementedError ( 'Currency code "%s" not implemented for "%s"' % ( currency , self . __class__ . __name__ ) ) if adjective and currency in self . CURRENCY_ADJECTIVES : cr1 = prefix_currency ( self . CURRENCY_ADJECTIVES [ currency ] , cr1 ) minus_str = "%s " % self . negword if is_negative else "" cents_str = self . _cents_verbose ( right , currency ) if cents else self . _cents_terse ( right , currency ) return u'%s%s %s%s %s %s' % ( minus_str , self . to_cardinal ( left ) , self . pluralize ( left , cr1 ) , separator , cents_str , self . pluralize ( right , cr2 ) )
Args:
            val: Numeric value
            currency (str): Currency code
            cents (bool): Verbose cents
            separator (str): Cent separator
            adjective (bool): Prefix currency name with adjective
        Returns:
            str: Formatted string
Args : val : Numeric value currency ( str ) : Currency code cents ( bool ) : Verbose cents separator ( str ) : Cent separator adjective ( bool ) : Prefix currency name with adjective Returns : str : Formatted string