import abc
class a(abc.ABC): @classmethod @property @abc.abstractmethod def x(cls): print("Hello world") class b(a): def x(*args): pass (NOTHING happens, the abstract method/property is overriden) class c(a): pass"HELLO WORLD" is printed, creating the class (not instanciating an object of that type but creating the class itself), because the abstract method/property is not overriden.
Note that the method is called at class creation time.if you replace the body of "x" method with a "raise NotImplementedError" you can produce that exception at import time, if some class remains abstract.
This is an interesting interaction between decorators trying to be clever supporting both regular and abstract methods/properties.
Trying to figure out how it worked took some time and python source code diving. I think this is interesting enough to share.
I don't think this is a bug to solve, just some brain teasing. I let other to decide what to do with this... collateral effect.
Let me know what do you think after trying to understand how it works. -- Jesús Cea Avión _/_/ _/_/_/ _/_/_/ j...@jcea.es - https://www.jcea.es/ _/_/ _/_/ _/_/ _/_/ _/_/ Twitter: @jcea _/_/ _/_/ _/_/_/_/_/ jabber / xmpp:j...@jabber.org _/_/ _/_/ _/_/ _/_/ _/_/ "Things are not so easy" _/_/ _/_/ _/_/ _/_/ _/_/ _/_/ "My name is Dump, Core Dump" _/_/_/ _/_/_/ _/_/ _/_/ "El amor es poner tu felicidad en la felicidad de otro" - Leibniz
OpenPGP_signature
Description: OpenPGP digital signature
_______________________________________________ Python-Dev mailing list -- python-dev@python.org To unsubscribe send an email to python-dev-le...@python.org https://mail.python.org/mailman3/lists/python-dev.python.org/ Message archived at https://mail.python.org/archives/list/python-dev@python.org/message/VJ5PWJNU325SVVIBTRPCEUYOERBKGNWA/ Code of Conduct: http://python.org/psf/codeofconduct/