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

ezio.melotti at gmail.com ezio.melotti at gmail.com
Fri May 10 20:18:59 CEST 2013


Added a few comments, mostly about style.


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

http://bugs.python.org/review/17947/diff/8108/Lib/enum.py#newcode2
Lib/enum.py:2: Provides the Enum class, which can be subclassed to
create new, static, enumerations.
Line too long.

http://bugs.python.org/review/17947/diff/8108/Lib/enum.py#newcode86
Lib/enum.py:86: if key in self._enum_names and self[key] != something:
Does this mean than defining the same element twice with the same value
is allowed?
Is there any reason to allow this?

http://bugs.python.org/review/17947/diff/8108/Lib/enum.py#newcode87
Lib/enum.py:87: raise TypeError('Attempted to reuse key: %s' % key)
Using %r is probably better.

http://bugs.python.org/review/17947/diff/8108/Lib/enum.py#newcode207
Lib/enum.py:207: + list(self.__members__))
The operator should go at the end of the previous line.

http://bugs.python.org/review/17947/diff/8108/Lib/enum.py#newcode244
Lib/enum.py:244: and base._enum_names):
The operator should go at the end of the previous line.

http://bugs.python.org/review/17947/diff/8108/Lib/enum.py#newcode270
Lib/enum.py:270: return obj_type, first_enum
You could simplify this a bit and save some indentation by doing:
if not bases:
    return object, Enum
for base in bases:
    ...

The same could also be done at line 252.

http://bugs.python.org/review/17947/diff/8108/Lib/enum.py#newcode284
Lib/enum.py:284: for possible in (obj_type, first_enum):
You could use sets here.

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


More information about the docs mailing list