[docs] Code, test, and doc review for PEP-0435 Enum (issue 17947)

ncoghlan at gmail.com ncoghlan at gmail.com
Sun May 12 15:28:03 CEST 2013


http://bugs.python.org/review/17947/diff/8113/Lib/enum.py
File Lib/enum.py (right):

http://bugs.python.org/review/17947/diff/8113/Lib/enum.py#newcode214
Lib/enum.py:214: return cls._enum_map.copy()
This kind of use case is exactly why types.MappingProxyType was made
visible at the Python layer (it's the impl of the read-only mappings
used for class dictionaries, and we use them there for a similar reason:
modifying the class contents without going through the class machinery
simply isn't something we want to allow).

So, rather than copying, I suggest returning
types.MappingProxyType(cls._enum_map)

http://docs.python.org/3/library/types#types.MappingProxyType

http://bugs.python.org/review/17947/


More information about the docs mailing list