[issue1734] documentation on metaclasses is incomplete and misleading
Georg Brandl added the comment: This should now be appropriately explained in the trunk, r59837. I also added an example of using __new__ in a metaclass. -- resolution: - fixed status: open - closed __ Tracker [EMAIL PROTECTED] http://bugs.python.org/issue1734 __ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue1734] documentation on metaclasses is incomplete and misleading
Changes by Georg Brandl: -- assignee: - georg.brandl __ Tracker [EMAIL PROTECTED] http://bugs.python.org/issue1734 __ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue1734] documentation on metaclasses is incomplete and misleading
L. Peter Deutsch added the comment: Actually, called and callable are OK, if the documentation says somewhere that the normal effect of calling a type object is to invoke __new__. The places I looked first (sections 3.1, 3.3, and 3.4.1) do not say this. 5.3.4 does say that the result of calling a class object is a new instance of that class, but it doesn't mention __new__. So perhaps it would OK to just add something like the following to 3.4.3: Note that if a metaclass is a subclass of codetype/code, it should override code__new__/code, not code__call__/code. __ Tracker [EMAIL PROTECTED] http://bugs.python.org/issue1734 __ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue1734] documentation on metaclasses is incomplete and misleading
L. Peter Deutsch added the comment: Please reopen this issue as a documentation bug. The documentation for __new__ in section 3.4.1 says: __new__() is intended mainly to allow subclasses of immutable types (like int, str, or tuple) to customize instance creation. The documentation for metaclasses in 3.4.3 says nothing about __new__ vs. __init__. It says the metaclass will be called for class creation, and it says the metaclass can be any callable. This would imply the use of __call__ rather than __new__ or __init__. I think 3.4.1 should say: __new__() is intended mainly to allow subclasses of immutable types (like int, str, or tuple) to customize instance creation. It is also used for custom metaclasses (q.v.). I think 3.4.3 should be reviewed in its entirety to replace the misleading language about called and callable with language that explicitly mentions __new__. -- title: no effect if metaclass modifies dict - documentation on metaclasses is incomplete and misleading __ Tracker [EMAIL PROTECTED] http://bugs.python.org/issue1734 __ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com