Most functions in a class will refer to a "self" instance.
If you want a static function, you'll have to add the @staticmethod decorator.
class Something(object):
@staticmethod
def get_by_name(name):
return "Hello world"
[ Source ]
Mainly notes to future-Twig (and for anyone else who may find them useful)
If you've found one or more of my blog posts helpful, why not say thanks by buying me a coffee or beer?
Most functions in a class will refer to a "self" instance.
If you want a static function, you'll have to add the @staticmethod decorator.
class Something(object):
@staticmethod
def get_by_name(name):
return "Hello world"
[ Source ]