On Wed, May 6, 2020 at 8:49 PM Ricky Teachey <ri...@teachey.org> wrote:
> >>> In the example above, self.b is assigned the value of b, not Enum(b). >>> And even if you called-- or gave the option to call-- func(*args, **kwargs) >>> first, autoassign still wouldn't know that you want to modify the supplied >>> parameter value. >>> >> >> But you could just write `self.b = MyEnum(b)`, and it would overwrite the >> auto-assigned `self.b = b`. >> > > I.... didn't think of that. In that case, though, you're assigning self.b > twice. If it is a descriptor, that might not be desirable and result in all > kinds of side effects. > 1. The combination of a non-idempotent descriptor and wanting to customise the input in `__init__` seems very rare. Since this is a convenience, I think it's fine to not support every use case. 2. The problem can be solved by putting the customisation in the descriptor, which is probably a good idea anyway. 3. A user would have to be particularly careless to do this by mistake and cause actual damage. It should be obvious from both a brief description of the decorator and some basic experimentation that it assigns to descriptors. A simple test of the user's actual code would also likely reveal this.
_______________________________________________ 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/MBMETIFR6OARP36JL5OYRBSBYA5PCSTT/ Code of Conduct: http://python.org/psf/codeofconduct/