Utilisez property () comme une simple fonction, pas comme un décorateur.
Utilisé dans SQLAlchemy. 
from operator import attrgetter
class A:
    def __init__(self):
        self.foo = "foo"
    f = property(attrgetter("foo"), doc="An alias for the :attr:`.foo` attribute.")
if __name__ == "__main__":
    help(A.f)
    a = A()
    print("A.foo:", a.foo)
    print("A.f:", a.f)
Exemple d'exécution.
$ python sample_alias.py
Help on property:
    An alias for the :attr:`.foo` attribute.
A.foo: foo
A.f: foo
Recommended Posts