[New-bugs-announce] [issue22506] `dir` on Enum subclass doesn't expose parent class attributes

Ram Rachum report at bugs.python.org
Sat Sep 27 16:57:25 CEST 2014


New submission from Ram Rachum:

Calling `dir` on an enum subclass shows only the contents of that class, not its parent classes. In normal classes, you can do this: 

    Python 3.4.0 (v3.4.0:04f714765c13, Mar 16 2014, 19:25:23) [MSC v.1600 64 bit (AMD64)] on win32
    Type "help", "copyright", "credits" or "license" for more information.
    >>> class A:
    ...   x = lambda self: 7
    ...
    >>> class B(a): pass
    ...
    >>> assert 'x' in dir(B)

But in enum subclasses, it fails:
    
    >>> import enum
    >>> class A(enum.Enum):
    ...   x = lambda self: 7
    ...
    >>> class B(A):
    ...   pass
    ...
    >>> assert 'x' in dir(B)
    Traceback (most recent call last):
      File "<stdin>", line 1, in <module>
    AssertionError
    >>>

Looks like the `__dir__` implementation needs to be tweaked.

----------
components: Library (Lib)
messages: 227681
nosy: cool-RR
priority: normal
severity: normal
status: open
title: `dir` on Enum subclass doesn't expose parent class attributes
type: behavior
versions: Python 3.4

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue22506>
_______________________________________


More information about the New-bugs-announce mailing list