[Django]-Accessing function as attribute in a Python class

83👍

You can use the @property decorator.

class foo(object):
    bar = "bar"
    @property
    def baz(self):
        return "baz"

17👍

Take a look at the decorator form of property.

@property
def baz(self):
  return "baz"

Leave a comment