https://github.com/brandon-rhodes/python-jplephem
Raw File
Tip revision: 0b72da7ae6faac82d48146295a2d8cbac9b393d1 authored by Brandon Rhodes on 26 March 2020, 16:41:21 UTC
Version 2.14
Tip revision: 0b72da7
descriptorlib.py
from functools import update_wrapper

class reify(object):
    """Adapted from Pyramid's `reify()` memoizing decorator."""
    def __init__(self, method):
        self.method = method
        update_wrapper(self, method)

    def __get__(self, instance, objtype=None):
        if instance is None:
            return self
        value = self.method(instance)
        instance.__dict__[self.__name__] = value
        return value
back to top