Background: I asked a stackoverflow question here 
<http://stackoverflow.com/questions/40029807/why-does-the-class-definitions-metaclass-keyword-argument-accept-a-callable>
.

The Python documentation 
<https://docs.python.org/3.6/reference/datamodel.html#determining-the-appropriate-metaclass>
 
is very confusing to me. It says that:

if an explicit metaclass is given and it is not an instance of type, then 
it is used directly as the metaclass

This seems to suggest that in this case, the "explicit metaclass" does not 
need to be "subtype of all of these candidate metaclasses" as it would in 
the third case.  (This is not true.)

Also, providing a callable as a metaclass doesn't seem to be any more 
flexible, readable, or powerful than providing an instance of type. 
 Therefore, I suggest that we deprecate the second case and replace the 
entire section (3.3.3.2) of the documentation to say:

"The metaclass of a class definition is selected from the explicitly 
specified metaclass (if any) and the metaclasses (i.e. type(cls)) of all 
specified base classes. The most derived metaclass is one which is a 
subtype of all of these candidate metaclasses. If none of the candidate 
metaclasses meets that criterion, then the class definition will fail with 
TypeError. If provided, the explicit metaclass must be an instance of 
type()."
_______________________________________________
Python-ideas mailing list
Python-ideas@python.org
https://mail.python.org/mailman/listinfo/python-ideas
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to