vimeo / py-money Goto Github PK
View Code? Open in Web Editor NEWMoney class for Python 3
License: MIT License
Money class for Python 3
License: MIT License
Hi!
I see that this library is no longer maintained.
We "forked" it internally at Backmarket, for our needs (custom rounding, removal of float support), and we were wondering if we could publish our version as a replacement of yours.
We do have an open source strategy internally.
Is it something you'd like to discuss? With who I can get in touch about that?
Thanks!
its forcing me to use babel 2.4.0 even if i already installed latest version of babel(2.6.0)
Hi!
The current implementation of __eq__
for Money
is too rigid and cannot be used for inclusion tests:
>>> from money.currency import Currency
>>> from money.money import Money
>>> x = Money('10.00', Currency.USD)
>>> x in (None, Money('10.00', Currency.USD))
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "<...>/lib/python3.7/site-packages/money/money.py", line 80, in __eq__
raise InvalidOperandError
money.exceptions.InvalidOperandError: Invalid operand types for operation
>>> x in (Money('10.00', Currency.USD), None)
True
Currency enum should be extending str
as weel to make it serializable to json by default. Currently it results with the error:
TypeError: <Currency.USD: 'USD'> is not JSON serializable
Changing definition to this should solve the issue:
class Currency(str, Enum):
...
And calling print(json.dumps(Currency.USD))
would correctly print: "USD"
.
Hi @nickyr, thanks for your work on this,
Out of curiosity, would you be open to including a change to the per-arithmetic operation rounding (https://github.com/vimeo/py-money/blob/master/money/money.py#L170)? If possible, I'd like to contribute a change back in to make that configurable.
Thanks!
I happen to be looking for python libraries related that offer some capability of major unit to minor unit conversion, and came across your repo. Just wanted to let you know that the sub_units in many currencies here https://github.com/vimeo/py-money/blob/master/money/currency.py are out of date. Ex: CLP, ISK, KRW, etc should have sub_unit as 1, not 100. The full list can be found here https://www.currency-iso.org/en/home/tables/table-a1.html.
I have my spare code:
#!/usr/bin/env python
# -*- coding: UTF-8 -*-
from money.money import Money
from money.currency import Currency
x = Money('0.01', Currency.GBP)
words = 'alphabet'
for i in words:
x += 0.01
print (x)
But when I run it it returns me:
Traceback (most recent call last):
File "test.py", line 11, in <module>
x += 0.01
File "C:\Program Files\Python36\lib\site-packages\money\money.py", line 81, in __add__
raise InvalidOperandError
money.exceptions.InvalidOperandError: Invalid operand types for operation
I believe +=
is the problem
$ pip install py-money
Collecting py-money
Could not find a version that satisfies the requirement py-money (from versions: )
No matching distribution found for py-money
Please upload a sdist or a wheel for OSX environments.
Would love to contribute my part if possible
This is what I'm looking for:
>>> m = Money('3.24')
>>> m.format(currency_digits=False)
$324
I would love to work on this if it hasn't been implemented yet
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.