[docs] [issue23292] Enum doc suggestion

Ethan Furman report at bugs.python.org
Sat Jan 24 03:41:40 CET 2015

Ethan Furman added the comment:

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


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:

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

nosy: +barry, eli.bendersky

Python tracker <report at bugs.python.org>

More information about the docs mailing list