Decorators

@property

Makes a function works like some variable.

class House():

@property
def temperature(self):
    return self._temperature*10

@temperature.setter
def temperature(self, temp):
    self._temprature = some_func(temp)
    
#use this as

house = House()
temp = house.temperature
house.temperature = 50.0

@classmethod and @staticmethod

See how you can create class instance through some other logic using @classmethod.

Last updated