def lazy_property ( function ) : cached_val = [ ] def _wrapper ( * args ) : try : return cached_val [ 0 ] except IndexError : ret_val = function ( * args ) cached_val . append ( ret_val ) return ret_val return _wrapper
python property to ensure function is also loaded once the first time it is called
Cache the first return value of a function for all subsequent calls .
def lazy_property(function):
    """Cache the first return value of a function for all subsequent calls.

    This decorator is usefull for argument-less functions that behave more
    like a global or static property that should be calculated once, but
    lazily (i.e. only if requested).
    """
    cached_val = []
    def _wrapper(*args):
        try:
            return cached_val[0]
        except IndexError:
            ret_val = function(*args)
            cached_val.append(ret_val)
            return ret_val
    return _wrapper