Why should __prepare__ be explicitly decorated as a @classmethod?

Chris Angelico rosuav at gmail.com
Sun May 18 03:18:22 EDT 2014


On Sun, May 18, 2014 at 4:26 PM, Shriramana Sharma <samjnaa at gmail.com> wrote:
> https://docs.python.org/3/reference/datamodel.html#basic-customization documents that __new__ is special-cased so that while it is actually a static method, it need not be decorated as such. I have a similar question. IIUC __prepare__ is always a class method to be used in metaclasses, so why isn't it also special-cased so that it need not be decorated as a such?

Special cases aren't special enough to break the rules. The less
special cases a language has, the more likely it is to fit inside your
brain, and that's a good thing.

ChrisA



More information about the Python-list mailing list