pydanny/cached-property

Add a way to check if a property has already been cached

Open

#32 opened on May 13, 2016

View on GitHub
 (2 comments) (0 reactions) (0 assignees)Python (79 forks)github user discovery
enhancementhelp wanted

Repository metrics

Stars
 (705 stars)
PR merge metrics
 (No merged PRs in 30d)

Description

Sometimes it's useful to be able to check if a property has been cached already. Currently I'm using something like:

    @cached_property
    def cachable(self): pass

    def a_function(self):
        if 'cachable' in self.__dict__:
            # Already cached.
        else:
            # Not cached yet.

(Haven't tested this, but I think it'ill work) Can we think of a better API?

Contributor guide