carlospalol / money

Python money class with optional CLDR-backed locale-aware formatting and an extensible currency exchange solution.
MIT License
230 stars 34 forks source link

amount = self._amount + other TypeError: unsupported operand type(s) for +: 'decimal.Decimal' and 'float' #27

Open francesco1119 opened 6 years ago

francesco1119 commented 6 years ago

I have my very easy code:

#!/usr/bin/env python
# -*- coding: UTF-8 -*-

from money import Money                             
x = Money(amount='0.01', currency='USD')

words = 'alphabet'

for i in words:
    x += 0.01

print (x)

But it just won't run:

Traceback (most recent call last):
  File "test.py", line 10, in <module>
    x += 0.01
  File "C:\Program Files\Python36\lib\site-packages\money\money.py", line 118, in __add__
    amount = self._amount + other
TypeError: unsupported operand type(s) for +: 'decimal.Decimal' and 'float'

I believe += is the problem. Any way out?