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)?
On Thu, Aug 6, 2020 at 01:13 email@example.com wrote:
I think a property decorator can be useful, because you consider the simplest case with:
class MyClass: @my_property name = arg
but consider it can generate the following code:
class MyClass: def name(self): ... def see_name(self): ...
Or consider the following example:
class MyClass: @factory strategy= arg
that can will generate:
class MyClass: class MyClassStrategy: ... strategy= MyClassStrategy(arg)
All it will be possible if attribute decorator will have the following signature:
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:
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 -- firstname.lastname@example.org To unsubscribe send an email to email@example.com https://mail.python.org/mailman3/lists/python-ideas.python.org/ Message archived at https://firstname.lastname@example.org/message/MCQBK7... Code of Conduct: http://python.org/psf/codeofconduct/