Skip to content

Instantly share code, notes, and snippets.

@filipgorczynski
Last active October 17, 2018 04:37
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 filipgorczynski/5e163943a2fc612bc3360fc99e1fe562 to your computer and use it in GitHub Desktop.
Save filipgorczynski/5e163943a2fc612bc3360fc99e1fe562 to your computer and use it in GitHub Desktop.
class Celsius:
__multiplier = 1.8
def __init__(self, temperature = 0):
self._temperature = temperature
def to_fahrenheit(self):
return (self._temperature * 1.8) + 32
def get_temperature(self):
print("Getting value")
return self._temperature
def set_temperature(self, value):
print("Setting value")
return None
temperature = property(get_temperature,set_temperature)
t1 = Celsius(23)
print(t1.to_fahrenheit())
t1.temperature = 45
t1.__multiplier = 10
print(t1.to_fahrenheit())
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment