A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://mail.python.org/pipermail/python-dev/2017-December/151296.html below:

[Python-Dev] __init_subclass__ is a class method (Was: Make __class_getitem__ a class method)

[Python-Dev] __init_subclass__ is a class method (Was: Make __class_getitem__ a class method) [Python-Dev] __init_subclass__ is a class method (Was: Make __class_getitem__ a class method)Serhiy Storchaka storchaka at gmail.com
Fri Dec 15 12:40:06 EST 2017
15.12.17 19:04, Ivan Levkivskyi пише:
> Good point! Pure Python will be the primary use case and we have another 
> precedent
> for "automatic" class method: __init_subclass__ (it does not need to be 
> decorated).

__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:

class A:
     def __init_subclass__(cls): pass

class B:
     @classmethod
     def __init_subclass__(cls): pass

help(A) shows __init_subclass__() as a class method (in 3.7).

But if you implement the class in C you need to make __init_subclass__ a 
class method.

I think __init_subclass__ should be documented as a class method since 
it is a class method.

More information about the Python-Dev mailing list

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4