code: def enum(cls):
      
  
      assert cls.__bases__ == (object,)
  
      d = dict(cls.__dict__)
      new_type = type(cls.__name__, (int,), d)
      new_type.__module__ = cls.__module__
  
      map_ = {}
      for key, value in iteritems(d):
          if key.upper() == key and isinstance(value, integer_types):
              value_instance = new_type(value)
              setattr(new_type, key, value_instance)
              map_[value] = key
  
      def str_(self):
          if self in map_:
              return "%s.%s" % (type(self).__name__, map_[self])
          return "%d" % int(self)
  
      def repr_(self):
          if self in map_:
              return "<%s.%s: %d>" % (type(self).__name__, map_[self], int(self))
          return "%d" % int(self)
  
      setattr(new_type, "__repr__", repr_)
      setattr(new_type, "__str__", str_)
  
      return new_type
docs: A decorator for creating an int enum class.
  
      Makes the values a subclass of the type and implements repr/str.
      The new class will be a subclass of int.
  
      Args:
          cls (type): The class to convert to an enum
  
      Returns:
          type: A new class
  
      ::
  
          @enum
          class Foo(object):
              FOO = 1
              BAR = 2