example-code-2e/25-class-metaprog/metabunch
2021-05-21 18:56:12 -03:00
..
from3.6 updade from Atlas repo 2021-05-21 18:56:12 -03:00
nutshell3e updade from Atlas repo 2021-05-21 18:56:12 -03:00
original updade from Atlas repo 2021-05-21 18:56:12 -03:00
pre3.6 updade from Atlas repo 2021-05-21 18:56:12 -03:00
README.md updade from Atlas repo 2021-05-21 18:56:12 -03:00

Examples from Python in a Nutshell, 3rd edition

The metaclass MetaBunch example in original/bunch.py is an exact copy of the last example in the How a Metaclass Creates a Class section of Chapter 4: Object Oriented Python from
Python in a Nutshell, 3rd edition by Alex Martelli, Anna Ravenscroft, and Steve Holden.

The version in pre3.6/bunch.py is slightly simplified by taking advantage of Python 3 super() and removing comments and docstrings, to make it easier to compare to the from3.6 version.

The version in from3.6/bunch.py is further simplified by taking advantage of the order-preserving dict that appeared in Python 3.6, as well as other simplifications, such as leveraging closures in __init__ and __repr__ to avoid adding a __defaults__ mapping to the class.

The external behavior of all three versions is the same, and the test files bunch_test.py are identical in the three directories.