class Calculator:
# create addNumbers static method
@staticmethod
def addNumbers(x, y):
return x + y
print('Product:', Calculator.addNumbers(15, 110))
class staticproperty(staticmethod):
def __get__(self, *args):
return self.__func__()
# use instead of @property decorator in your class
import random
class Example:
# A static method doesn't take the self argument and
# cannot access class members.
@staticmethod
def choose(l: list) -> int:
return random.choice(l)
def __init__(self, l: list):
self.number = self.choose(l)
STATIC_ROOT = os.path.join(BASE_DIR, 'static')
STATICFILES_DIRS = [
os.path.join(BASE_DIR, 'checkstatic/static/')
]
class A(object):
@staticmethod
def stat_meth():
print("Look no self was passed")
>>> a = A()
>>> a.stat_meth()
Look no self was passed