You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
15 lines
407 B
15 lines
407 B
class ClassPropertyDescriptor(object):
|
|
"""Based on https://stackoverflow.com/questions/5189699/how-to-make-a-class-property"""
|
|
|
|
def __init__(self, fget):
|
|
self.fget = fget
|
|
|
|
def __get__(self, obj, klass):
|
|
if klass is None:
|
|
klass = type(obj)
|
|
return self.fget.__get__(obj, klass)()
|
|
|
|
|
|
def classproperty(func):
|
|
return ClassPropertyDescriptor(classmethod(func))
|