Read-onlyなclasspropertyデコレータの実装

class classproperty(property):
    def __init__(self, fget):
        super(classproperty, self).__init__(fget)
        self.__doc__ = fget.__doc__

    def __get__(desc, self, cls):
        return desc.fget(cls)


class A(object):
    @classproperty
    def __tablename__(cls):
        return cls.__name__.lower()

class B(A):
    pass

print(A.__tablename__)
print(B.__tablename__)