On Sat, Aug 08, 2020 at 10:22:20PM -0000, Roger Serwy wrote: > The property decorator, with its .setter and .deleter chaining, is a > bit cumbersome and repetitive. If we can add `.apply` as a method on > property that calls a function that returns the fget/fset/fdel/doc > arguments, it would simplify instantiating the descriptor. For > example:
You don't need an apply method for that, property already takes four arguments, so you can write: def factory(): def fget(self): pass def fset(self, value): pass def fdel(self): pass return (fget, fset, fdel, "doc") attr = property(*factory()) # optional: del factory but frankly, having to write the property getters and setters as nested functions is (in my opinion) uglier looking and more annoying than the usual property chaining version. So if you want to use this with decorator notation, you need a one-line helper: def myproperty(func): return property(*func()) and change the name of "factory" to "attr". -- Steven _______________________________________________ Python-ideas mailing list -- python-ideas@python.org To unsubscribe send an email to python-ideas-le...@python.org https://mail.python.org/mailman3/lists/python-ideas.python.org/ Message archived at https://mail.python.org/archives/list/python-ideas@python.org/message/AWY3ORTCRR6KVGV4KEUNURUZUFGSCKWK/ Code of Conduct: http://python.org/psf/codeofconduct/