Hi everyone,

I have a function which accepts an alpha2 country code and a price string,
where the aim is to get the country's currency and use the currency.letter
property of that currency to format the supplied price string.

The above works fine so far - yet it falls over when called with Germany as
the country as follows:

currency = pycountry.currencies.get(numeric=country.numeric)

The function implementation is as follows:

def formatPrice(self, alpha2CountryCode, price):
        """
        @param alpha2CountryCode: The 2-character country code for which to
format the price value
        @param price: The price value as a string
        @return: A string representing the formatted monetary value for
this country for this price.

        #Get country by alpha2 code
        country = pc.countries.get(alpha2=alpha2CountryCode.upper())

        #Get currency by country's numeric and format price
        currency = pc.currencies.get(numeric=country.numeric)
        letter = currency.letter
        formattedCurrency = "%s %s" % (letter, price)

        return formattedCurrency

Any ideas as to what the issue may be?

Thanks :)

-- 
Regards,
Sithu Lloyd Dube

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAH-SnCD4j8Ae5Qtbg%3DLQQJeQettxgbA4zcwRDDDvSS6copZgaw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to