Alir3z4 / python-currencies

Display money format and its filthy currencies, for all money lovers out there.
http://pypi.python.org/pypi/currencies
GNU General Public License v3.0
72 stars 13 forks source link

Countries for currencies #6

Open jusce17 opened 3 years ago

jusce17 commented 3 years ago

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'
Alir3z4 commented 3 years ago

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.

eumiro commented 3 years ago

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.