<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On 15 December 2017 at 18:40, Serhiy Storchaka <span dir="ltr"><<a href="mailto:storchaka@gmail.com" target="_blank">storchaka@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">15.12.17 19:04, Ivan Levkivskyi пише:<br>
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
Good point! Pure Python will be the primary use case and we have another precedent<br>
for "automatic" class method: __init_subclass__ (it does not need to be decorated).<br>
</blockquote>
<br>
__init_subclass__ is very different beast, and parallels with it can be confusing. It is automatically decorated with classmethod if it is a regular function implemented in C. The following two examples are totally equivalent:<br>
<br>
class A:<br>
    def __init_subclass__(cls): pass<br>
<br>
class B:<br>
    @classmethod<br>
    def __init_subclass__(cls): pass<br>
<br>
help(A) shows __init_subclass__() as a class method (in 3.7).<br>
<br>
But if you implement the class in C you need to make __init_subclass__ a class method.<br>
<br>
I think __init_subclass__ should be documented as a class method since it is a class method.<br></blockquote></div></div><div class="gmail_extra"><br></div><div class="gmail_extra">Thank you for clarification!</div><div class="gmail_extra">Actually documentation <a href="https://docs.python.org/3.6/reference/datamodel.html#customizing-class-creation">https://docs.python.org/3.6/reference/datamodel.html#customizing-class-creation</a> already says `classmethod object.__init_subclass__(cls)`</div><div class="gmail_extra">I am not an expert in this, so I am not sure if the docs can be improved here (maybe we can add how this works with C API?)<br></div><div class="gmail_extra"><br></div><div class="gmail_extra">--</div><div class="gmail_extra">Ivan</div><div class="gmail_extra"><br></div><div class="gmail_extra"><br></div></div>