def lazyattr(fget):

    name = fget.__name__

    def newfget(self):
        mydict = self.__dict__
        if name in mydict:
            return mydict[name]
        mydict[name] = value = fget(self)
        return value

    return property(newfget, None, None, fget.__doc__)
Create a *lazy attribute* from the result of `fget`.
dataset/ETHPy150Open PyTables/PyTables/tables/utils.py/lazyattr