diff options
author | Sylvain <syt@logilab.fr> | 2007-10-26 14:47:40 +0200 |
---|---|---|
committer | Sylvain <syt@logilab.fr> | 2007-10-26 14:47:40 +0200 |
commit | c671676addcd91a405c9e580c5677be0db159036 (patch) | |
tree | a488d63f3de00eb38257832e5b5565ea593e91ad /decorators.py | |
parent | d0143399410e7504014dc70e4e42e5e5f26b02f1 (diff) | |
download | logilab-common-c671676addcd91a405c9e580c5677be0db159036.tar.gz |
new classproperty decorator
Diffstat (limited to 'decorators.py')
-rw-r--r-- | decorators.py | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/decorators.py b/decorators.py index 46ceabd..1abd54b 100644 --- a/decorators.py +++ b/decorators.py @@ -101,6 +101,12 @@ class wproperty(object): assert obj is not None return getattr(obj, self.attrname) +class classproperty(object): + def __init__(self, get): + self.get = get + def __get__(self, inst, cls): + return self.get(cls) + from time import clock def timed(f): def wrap(*args, **kwargs): @@ -110,3 +116,4 @@ def timed(f): print '%s time: %.9f' % (f.__name__, clock() - t) return res return wrap + |