Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Single Currency #21

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

allonhadaya
Copy link

Create a factory function single which binds a given currency to a single currency class.

@allonhadaya
Copy link
Author

Perhaps the example code should read:

BTC = Single('BTC')

Rather than:

class BTC(Single('BTC')):
    # demonstrates the ability to do subclassy stuff
    pass

@allonhadaya
Copy link
Author

Single might be a bad name since it doesn't explicitly have to do with money.


Perhaps it could be renamed to:

Currency

  • I like that Currency is easy to type and is expressive, but I'd be afraid to confuse users about currency and Currency.
  • While they are related, users might mistakenly think that Currency is the type of currency, rather than a subclass of Money that has an implicit currency.

SingleCurrency

  • is kind of long, but the best so far

FixedCurrency

  • ?

@korg
Copy link

korg commented Mar 14, 2021

Could this be a decorator?

import money

def SingleCurrency(currencycode):
    def money_create(value):
        return money.Money(value,currencycode)
    return money_create

aud=SingleCurrency('AUD')
print(aud(10))

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants