I am trying different things to understand Decorators and functions in Python. Is the below code correct way :
import math
def calculate_area(func):
def area(a,b):
return a+b
return area
class Donut():
def __init__(self, outer, inner):
self.inner = inner
self.outer = outer
@calculate_area
@staticmethod
def area(self):
outer, inner = self.radius, self.inner
return Circle(outer).area() - Circle(inner).area()
Will "staticmenthod" decorator tells the built-in default metaclass type (the class of a class, cf. this question) to not create bound methods ? is it possible to do :
Donut.area(4,5)
Traceback (most recent call last):
File "<pyshell#33>", line 1, in <module>
Donut.area(4,5)
TypeError: unbound method area() must be called with Donut instance as first argument (got int instance instead)
Please help me in understanding bound methods and unbound methods and what it the impact of decorator on them.