Skip to content

Instantly share code, notes, and snippets.

@travishen
Created May 13, 2022 11:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save travishen/58dbfe7169b89636c22c330e39f782c6 to your computer and use it in GitHub Desktop.
Save travishen/58dbfe7169b89636c22c330e39f782c6 to your computer and use it in GitHub Desktop.
class CartItem:
def __init__(self, weight):
self.weight = weight
def get_weight(self):
return self.__weight
def set_weight(self, val):
if val > 0:
self.__weight = val
else:
raise ValueError()
weight = property(get_weight, set_weight)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment