objects.py 文件源码

python
阅读 29 收藏 0 点赞 0 评论 0

项目:fandango 作者: tango-controls 项目源码 文件源码
def getCachedObject(obj,methods=[],depth=10.,expire=3.,catched=False):
        """ @RISKY
        This method will try to apply Cached decorator to all methods 
        of an object. USE IT AT YOUR OWN RISK!!
        """
        klass = obj if isinstance(obj,type) else type(obj)
        if not methods:
            methods = [k for k,f in klass.__dict__.items() if isCallable(f)]
        for k in methods:
            try:
                m = Cached(getattr(klass,k),depth,expire,catched=catched)
                setattr(obj,k,m)
            except:pass
        return obj
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号