def lazyproperty(f):
    cache_attr_name = '_%s' % f.__name__  # like '_foobar' for prop 'foobar'
    docstring = f.__doc__

    def get_prop_value(obj):
        try:
            return getattr(obj, cache_attr_name)
        except AttributeError:
            value = f(obj)
            setattr(obj, cache_attr_name, value)
            return value

    return property(get_prop_value, doc=docstring)
@lazyprop decorator. Decorated method will be called only on first access
dataset/ETHPy150Open scanny/python-pptx/pptx/util.py/lazyproperty