Ethan Furman added the comment:

Currently the way to add an Enum's members to a module's namespace is:

  globals().update(MyEnumeration.__members__)

but that seems quite ugly.  Is there anywhere else that the user is required to 
use __xxx__ methods for common functionality?

I think a new method, export_to(), would solve the problem much more nicely:

  @classmethod
  def export_to(cls, namespace):
      try:
          # assume a dict-like namespace
          namespace.update(cls.__members__)
      except AttributeError:
          # or an object-like namespace
          for name, member in cls.__members__.items():
              setattr(namespace, name, member)

----------
nosy: +barry, eli.bendersky

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue23292>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to