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 <rep...@bugs.python.org>
<http://bugs.python.org/issue22506>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to