watson.common.decorators

class watson.common.decorators.cached_property(func)[source]

Allows expensive property calls to be cached.

Once the property is called, it’s result is stored in the corresponding property name prefixed with an underscore.

Example:

class MyClass(object):
    @cached_property
    def expensive_call(self):
        # do something expensive

klass = MyClass()
klass.expensive_call  # initial call is made
klass.expensive_call  # return value is retrieved from an internal cache
del klass._expensive_call
__init__(func)[source]
watson.common.decorators.instance_set(ignore=None)[source]

Allows initial binding of arguments to an __init__ method.

Example:

class MyClass(object):
    value = None

    @instance_set
    def __init__(self, value="Instance variable declaration"):
        pass

klass = MyClass()
klass.value  # Bound Value