
Maybe I’m lacking context, but I don’t understand the proposal. Can you explain the semantics and syntax you have in mind in more detail? How do you get from the first example (@my_property etc.) to the second (def name, def set_name)? —Guido On Thu, Aug 6, 2020 at 01:13 <redradist@gmail.com> wrote:
I think a property decorator can be useful, because you consider the simplest case with: ```python class MyClass: @my_property name = arg ``` but consider it can generate the following code: ```python class MyClass: def name(self): ...
def see_name(self): ... ``` Or consider the following example: ```python class MyClass: @factory strategy= arg ``` that can will generate: ```python class MyClass: class MyClassStrategy: ...
strategy= MyClassStrategy(arg) ```
All it will be possible if attribute decorator will have the following signature: ```python def factory(name, value, self, cls): # Where name - name of the property # value - initial value of the property # self - instance of created object before call __init__ # cls - class object (MyClass) ... ``` of course some of properties could be omitted like this: ```python def factory(name, value, cls): # Where name - name of the property # value - initial value of the property # cls - class object (MyClass) ... ```
As you can see property decorators could be very powerful thing if it will done right ;) _______________________________________________ Python-ideas mailing list -- python-ideas@python.org To unsubscribe send an email to python-ideas-leave@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/MCQBK7... Code of Conduct: http://python.org/psf/codeofconduct/
-- --Guido (mobile)