On Tue, Sep 29, 2020 at 4:53 PM Bar Harel <bzvi7...@gmail.com> wrote:

> I'd like to bring another insight to the table: According to the pep, 
> "Dynamically
> adding abstract methods to a class, or attempting to modify the abstraction
> status of a method or class once it is created, are not supported."
>
> The notice exists both in the pep and at the abc module's docs, and is
> exactly what this idea is all about.
>
> My question is why? Was there an objection for implementing such a thing,
> or was it complex enough to postpone for the time being?
>

I think this is fine. The "abstract-ness" of a class is not supposed to
change throughout its lifetime. The problem arises when decorators change
the class before it's ever used, as that should still be considered its
"initialization" as far as the user is concerned, so its "abstract-ness"
should change accordingly.
I agree with Guido in that the cleanest solution is to change the
decorators. Perhaps a module function to recalculate a class's
__abstractmethods __, that mixin decorators can call prior to returning the
class. I can't really think of standard library class decorators that would
use this global function other than `dataclass` and `total_ordering`, but
in this way, 3rd party decorators can easily support implementing abstract
functions.
The one downside to this solution is that it can easily be abused by
calling it in the middle of a class's lifetime.
_______________________________________________
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/AFGUJ4B3WMIOR4BTSY5TI5M5EZTVVRYM/
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to