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

eliben at gmail.com eliben at gmail.com
Sun May 12 15:38:28 CEST 2013

File Lib/enum.py (right):

Lib/enum.py:214: return cls._enum_map.copy()
On 2013/05/12 15:28:03, Nick Coghlan wrote:
> 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
> 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

Oh cool, I didn't know that existed (*blush*). Looks like a great
solution that addresses both concerns.


More information about the docs mailing list