Created
May 16, 2022 07:29
-
-
Save travishen/23e77251821d5bc5ab29d51baa7d41d3 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def quantity(storage_name): | |
def getter(instance): | |
return instance.__dict__[storage_name] | |
def setter(instance, value): | |
if value > 0: | |
instance.__dict__[stoage_name] = value | |
raise ValueError() | |
return property(getter, setter) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment