def fib(n):
if n == 0 or n == 1:
return n
else:
return fib(n - 1) + fib(n - 2)
@staticmethod
doesn’t need access to the object propertiesdoesn’t need to know the name, age, etc. All it needs to know (in the SWgame example) is whether or not it was a SithLord or a JediMaster
Static methods in Python are extremely similar to python class level methods, the difference being that a static method is bound to a class rather than the objects for that class. This means that a static method can be called without an object for that class. This also means that static methods cannot modify the state of an object as they are not bound to it. Let’s see how we can create static methods in Python.