parameters: (cls, class_name, names=None, module=None, type=None, start=1)
return_statement: return enum_class
docstring: Convenience method to create a new Enum class.
  
          `names` can be:
  
          * A string containing member names, separated either with spaces or
            commas.  Values are auto-numbered from 1.
          * An iterable of member names.  Values are auto-numbered from 1.
          * An iterable of (member name, value) pairs.
          * A mapping of member name -> value.
docstring_summary: Convenience method to create a new Enum class.
docstring_tokens: Convenience method to create a new Enum class .
function: def _create_(cls, class_name, names=None, module=None, type=None, start=1):
          """Convenience method to create a new Enum class.
  
          `names` can be:
  
          * A string containing member names, separated either with spaces or
            commas.  Values are auto-numbered from 1.
          * An iterable of member names.  Values are auto-numbered from 1.
          * An iterable of (member name, value) pairs.
          * A mapping of member name -> value.
  
          """
          if pyver < 3.0:
              # if class_name is unicode, attempt a conversion to ASCII
              if isinstance(class_name, unicode):
                  try:
                      class_name = class_name.encode('ascii')
                  except UnicodeEncodeError:
                      raise TypeError('%r is not representable in ASCII' % class_name)
          metacls = cls.__class__
          if type is None:
              bases = (cls, )
          else:
              bases = (type, cls)
          classdict = metacls.__prepare__(class_name, bases)
          _order_ = []
  
          # special processing needed for names?
          if isinstance(names, basestring):
              names = names.replace(',', ' ').split()
          if isinstance(names, (tuple, list)) and isinstance(names[0], basestring):
              names = [(e, i+start) for (i, e) in enumerate(names)]
  
          # Here, names is either an iterable of (name, value) or a mapping.
          item = None  # in case names is empty
          for item in names:
              if isinstance(item, basestring):
                  member_name, member_value = item, names[item]
              else:
                  member_name, member_value = item
              classdict[member_name] = member_value
              _order_.append(member_name)
          # only set _order_ in classdict if name/value was not from a mapping
          if not isinstance(item, basestring):
              classdict['_order_'] = _order_
          enum_class = metacls.__new__(metacls, class_name, bases, classdict)
  
          # TODO: replace the frame hack if a blessed way to know the calling
          # module is ever developed
          if module is None:
              try:
                  module = _sys._getframe(2).f_globals['__name__']
              except (AttributeError, ValueError):
                  pass
          if module is None:
              _make_class_unpicklable(enum_class)
          else:
              enum_class.__module__ = module
  
          return enum_class
function_tokens: def _create_ ( cls , class_name , names = None , module = None , type = None , start = 1 ) : if pyver < 3.0 : # if class_name is unicode, attempt a conversion to ASCII if isinstance ( class_name , unicode ) : try : class_name = class_name . encode ( 'ascii' ) except UnicodeEncodeError : raise TypeError ( '%r is not representable in ASCII' % class_name ) metacls = cls . __class__ if type is None : bases = ( cls , ) else : bases = ( type , cls ) classdict = metacls . __prepare__ ( class_name , bases ) _order_ = [ ] # special processing needed for names? if isinstance ( names , basestring ) : names = names . replace ( ',' , ' ' ) . split ( ) if isinstance ( names , ( tuple , list ) ) and isinstance ( names [ 0 ] , basestring ) : names = [ ( e , i + start ) for ( i , e ) in enumerate ( names ) ] # Here, names is either an iterable of (name, value) or a mapping. item = None # in case names is empty for item in names : if isinstance ( item , basestring ) : member_name , member_value = item , names [ item ] else : member_name , member_value = item classdict [ member_name ] = member_value _order_ . append ( member_name ) # only set _order_ in classdict if name/value was not from a mapping if not isinstance ( item , basestring ) : classdict [ '_order_' ] = _order_ enum_class = metacls . __new__ ( metacls , class_name , bases , classdict ) # TODO: replace the frame hack if a blessed way to know the calling # module is ever developed if module is None : try : module = _sys . _getframe ( 2 ) . f_globals [ '__name__' ] except ( AttributeError , ValueError ) : pass if module is None : _make_class_unpicklable ( enum_class ) else : enum_class . __module__ = module return enum_class