-
Notifications
You must be signed in to change notification settings - Fork 0
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
Ability to remove a coin #2
Comments
I like the comment from @PatrickHugh:
class Coin:
subcoins = []
def __init_subclass__(cls):
Coin.subcoins.append(cls)
@classmethod
def remove_subcoin(cls, coin):
Coin.subcoins.remove(cls) Then instead of |
Might be best to mark the list tracking the coins private.
class Coin:
_subcoins = set()
def __init_subclass__(cls):
Coin._subcoins.add(cls)
@classmethod
def remove_subcoin(cls, coin):
Coin._subcoins.remove(cls) |
Coins can be created by subclassing
Coin
, but once created they can't be removed.See: https://stackoverflow.com/q/52428679/7220776
The text was updated successfully, but these errors were encountered: