class classproperty(object):

    def __init__(self, getter):
        self.getter = getter

def __get__(self, instance, owner):
    return self.getter(owner)


class Foo(object):
    x = 4

@classproperty
def number(cls):
    return cls.x
Foo().number
Foo.number
How to create a read-only class property in Python?