def to_dict ( cls ) : return dict ( ( item . name , item . number ) for item in iter ( cls ) )
enumerate python all instances
Make dictionary version of enumerated class .
def to_dict(cls):
        """Make dictionary version of enumerated class.

        Dictionary created this way can be used with def_num.

        Returns:
          A dict (name) -> number
        """
        return dict((item.name, item.number) for item in iter(cls))