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?

On Tue, Sep 29, 2020 at 2:51 PM Bar Harel <bzvi7919@gmail.com> wrote:
I think it can be easily solved much like a normal bug fix - upon instance creation and before throwing an "ABC doesn't implement..." error, recheck the class __dict__ or even mro using hasattr, and only then throw the exception.

It will slow down only the specific course where the methods were defined dynamically. Plus it'll support dynamic __getattr__ on a child metaclass as an added bonus.

Bar Harel. 

On Thu, Sep 24, 2020, 7:28 PM Ben Avrahami <avrahami.ben@gmail.com> wrote:


On Thu, Sep 24, 2020 at 7:02 PM Eric V. Smith <eric@trueblade.com> wrote:

Does anyone know if attrs handles this? I don't have a recent version installed, but I'll take a look later today.


attrs handles this only if you set slots=True (which makes sense since attrs would have to rebuild the class)
_______________________________________________
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/KLMQ7HDYED32XGJAUCDHCVDDJJ2BX63V/
Code of Conduct: http://python.org/psf/codeofconduct/