Commits

Atsushi Odagiri committed b5362a2 Draft

support py3k

Comments (0)

Files changed (2)

     except:
         return ""
 
-version = '0.0'
+version = '0.1'
 
 readme = _read("README.txt")
 setup(name='standardenum',

src/standardenum/__init__.py

         super(EnumType, cls).__init__(name, bases, dct)
         cls._values = []
 
-        for key, value in dct.iteritems():
+        for key, value in dct.items():
             if not key.startswith('_'):
                 v = cls(key, value)
                 setattr(cls, key, v)
         return iter(cls._values)
 
 
-class StandardEnum(object):
 
-    __metaclass__ = EnumType
+def StandardEnum__init__(self, k, v):
+    self.v = v
+    self.k = k
 
-    def __init__(self, k, v):
-        self.v = v
-        self.k = k
+def StandardEnum__repr__(self):
+    return "<%s.%s value=%s>" % (self.__class__.__name__, self.k, self.v)
 
-    def __repr__(self):
-        return "<%s.%s value=%s>" % (self.__class__.__name__, self.k, self.v)
+def StandardEnum__str__(self):
+    return str(self.v)
 
-    def __str__(self):
-        return str(self.v)
+def StandardEnum__int__(self):
+    return int(self.v)
 
-    def __int__(self):
-        return int(self.v)
+def StandardEnum__long__(self):
+    return long(self.v)
 
-    def __long__(self):
-        return long(self.v)
+def StandardEnum__float__(self):
+    return float(self.v)
 
-    def __float__(self):
-        return float(self.v)
+def StandardEnum__complex__(self):
+    return complex(self.v)
 
-    def __complex__(self):
-        return complex(self.v)
-
-
+StandardEnum = EnumType(
+    "StandardEnum",
+    (object,),
+    dict(
+        __init__=StandardEnum__init__,
+        __repr__=StandardEnum__repr__,
+        __str__=StandardEnum__str__,
+        __int__=StandardEnum__int__,
+        __long__=StandardEnum__long__,
+        __float__=StandardEnum__float__,
+        __complex__=StandardEnum__complex__,
+    ),    
+)
 
 if __name__ == '__main__':
     import doctest