Quantcast
Channel: MarsHut
Viewing all articles
Browse latest Browse all 6551

Why should __prepare__ be explicitly decorated as a @classmethod?

$
0
0
Hello. I did search for this but couldn't find the info anywhere else, so I'm asking here. Please point out if I've missed some other source of the same info:

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?

Thanks.

Viewing all articles
Browse latest Browse all 6551

Trending Articles