Created
September 26, 2023 06:57
-
-
Save nenetto/f4c7b840bd39fcaa5419bca8ca87f2c4 to your computer and use it in GitHub Desktop.
Properties example
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
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