Accessing function as attribute in a Python class

Solution 1:

You can use the @property decorator.

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

Solution 2:

Take a look at the decorator form of property.

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