Skip to content

Instantly share code, notes, and snippets.

@nenetto
Created September 26, 2023 06:57
Show Gist options
  • Save nenetto/f4c7b840bd39fcaa5419bca8ca87f2c4 to your computer and use it in GitHub Desktop.
Save nenetto/f4c7b840bd39fcaa5419bca8ca87f2c4 to your computer and use it in GitHub Desktop.
Properties example
class FixedResistance(Resistor):
@property
def ohms(self):
return self._ohms
@ohms.setter
def ohms(self, ohms):
if hasattr(self, ‘_ohms’):
raise AttributeError(“Can’t set attribute”)
self._ohms = ohms
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment