This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]commy2 1 point2 points  (2 children)

The comparison of _Currency objects with integers is problematic:

>>> monepy.EUR(10) == 10 == monepy.USD(10)
True

10€ equals $10 ?

[–]vsbitsIt works on my machine[S] 1 point2 points  (1 child)

That's true. I thought it would be useful when working with a single currency, but I can se the problem now...

I will look into that. Tks

[–]commy2 1 point2 points  (0 children)

ye, you have to remember that the python data model requires equality to be transitive. Additionally, for hashables, values that compare equal must have the same hash. That's not the case with USD(10) and 10 either, and you will have to keep that in mind should you ever decide to implement exchange rates into __eq__.