This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: New metaclass example for Data Model topic
Type: enhancement Stage: patch review
Components: Documentation Versions: Python 3.8, Python 3.7, Python 3.6
process
Status: open Resolution:
Dependencies: Superseder:
Assigned To: docs@python Nosy List: adelfino, docs@python, methane, miss-islington, rhettinger
Priority: normal Keywords: patch

Created on 2018-06-09 17:59 by adelfino, last changed 2022-04-11 14:59 by admin.

Pull Requests
URL Status Linked Edit
PR 7566 merged adelfino, 2018-06-09 20:06
PR 10567 merged miss-islington, 2018-11-16 11:42
PR 10568 merged miss-islington, 2018-11-16 11:42
Messages (7)
msg319166 - (view) Author: Andrés Delfino (adelfino) * (Python triager) Date: 2018-06-09 17:59
Since Python 3.6, when PEP 520 was accepted, class attribute definition order is preserved. That alone is sufficient to replace the example, but then 3.7 came with guaranteed dictionary insertion order. The metaclass example uses OrderedDict, what may cause confusing to new programmers, since it is not needed.

I'm creating this issue in case someone who actually has used metaclasses can come up with an example, but I'll try to find/think of an example myself.
msg319167 - (view) Author: Andrés Delfino (adelfino) * (Python triager) Date: 2018-06-09 18:00
I'm talking about the example in Data Model, 3.3.3.6.
msg319176 - (view) Author: Raymond Hettinger (rhettinger) * (Python committer) Date: 2018-06-09 19:54
Probably, the entire section with the OrderedClass example should be removed.  Once class dicts became ordered by default, the __prepare__ attribute lost its principal motivating use case.
msg319178 - (view) Author: Andrés Delfino (adelfino) * (Python triager) Date: 2018-06-09 20:01
To what section are you refering by "the entire section"?

On a side note: I'll make a PR to remove the example. IMHO, there should be an example to give some idea of what a metaclass can do, but the current example is no longer useful and it's confusing because of how dicts now work.
msg329989 - (view) Author: Inada Naoki (methane) * (Python committer) Date: 2018-11-16 11:42
New changeset c2ccac7b9f9a1132ca36255b0ddfeecef4371aa3 by INADA Naoki (Andrés Delfino) in branch 'master':
bpo-33816: Remove outdated metaclass example (GH-7566)
https://github.com/python/cpython/commit/c2ccac7b9f9a1132ca36255b0ddfeecef4371aa3
msg329990 - (view) Author: miss-islington (miss-islington) Date: 2018-11-16 11:51
New changeset 1b80a373d104480c51cacb8b07ec3b61e21d5fa0 by Miss Islington (bot) in branch '3.7':
bpo-33816: Remove outdated metaclass example (GH-7566)
https://github.com/python/cpython/commit/1b80a373d104480c51cacb8b07ec3b61e21d5fa0
msg329991 - (view) Author: miss-islington (miss-islington) Date: 2018-11-16 11:58
New changeset 46fa7a60e08fc7486ecab726af93fa2cfe225305 by Miss Islington (bot) in branch '3.6':
bpo-33816: Remove outdated metaclass example (GH-7566)
https://github.com/python/cpython/commit/46fa7a60e08fc7486ecab726af93fa2cfe225305
History
Date User Action Args
2022-04-11 14:59:01adminsetgithub: 77997
2018-11-16 11:58:12miss-islingtonsetmessages: + msg329991
2018-11-16 11:51:23miss-islingtonsetnosy: + miss-islington
messages: + msg329990
2018-11-16 11:42:25miss-islingtonsetpull_requests: + pull_request9817
2018-11-16 11:42:13miss-islingtonsetpull_requests: + pull_request9816
2018-11-16 11:42:04methanesetnosy: + methane
messages: + msg329989
2018-06-09 20:06:49adelfinosetkeywords: + patch
stage: patch review
pull_requests: + pull_request7197
2018-06-09 20:01:51adelfinosetmessages: + msg319178
2018-06-09 19:54:22rhettingersetnosy: + rhettinger
messages: + msg319176
2018-06-09 18:00:40adelfinosetmessages: + msg319167
2018-06-09 17:59:20adelfinocreate