python-currencies icon indicating copy to clipboard operation
python-currencies copied to clipboard

Countries for currencies

Open jusce17 opened this issue 5 years ago • 2 comments

Would be nice if you could just write the country and get the currency, like


>>> portugal = Country('PORTUGAL')
>>> portugal.get_currency()
>>> EUR
>>> portugal.get_money_format(13)
>>> '€13'
>>> portugal.get_money_format(13.99)
>>> '€13.99'
>>> portugal.get_money_format('13,2313,33')
>>> '€13,2313,33'
>>>
>>> # Displaying with currency as well
>>>
>>> portugal.get_money_with_currency_format(13)
>>> '€13 EUR'
>>> portugal.get_money_with_currency_format(13.99)
>>> '€13.99 EUR'
>>> portugal.get_money_with_currency_format('13,2313,33')
>>> '€13,2313,33 EUR'

jusce17 avatar Dec 12 '20 10:12 jusce17

This would be good. I guess, it can be done via dictionary that has the Country ISO (not the country name as you suggested for instance for United Sates, could be US) as the key and currency for the value and then get the value to lookup the currency.

I'd suggest to work it up as a the Enum which could help to keep it clean. Soon, I'll add type checking via mypy etc and it would be great to have a full type hints on the code base as well.

Feel free to make a pull request, I'll try to review and give suggestion and get it merged quickly.

Alir3z4 avatar Dec 12 '20 16:12 Alir3z4

Another country-specific enhancement (especially for EUR that is used in countries with so many different languages) would be the number format, such as decimal comma/point or thousands separator as space, point, or comma.

eumiro avatar Dec 21 '20 17:12 eumiro