summaryrefslogtreecommitdiff
path: root/decorators.py
diff options
context:
space:
mode:
authorSylvain <syt@logilab.fr>2007-10-26 14:47:40 +0200
committerSylvain <syt@logilab.fr>2007-10-26 14:47:40 +0200
commitc671676addcd91a405c9e580c5677be0db159036 (patch)
treea488d63f3de00eb38257832e5b5565ea593e91ad /decorators.py
parentd0143399410e7504014dc70e4e42e5e5f26b02f1 (diff)
downloadlogilab-common-c671676addcd91a405c9e580c5677be0db159036.tar.gz
new classproperty decorator
Diffstat (limited to 'decorators.py')
-rw-r--r--decorators.py7
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
+