[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


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()
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
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

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

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


More information about the docs mailing list