]> Repositories - hackapet/Adafruit_Blinka.git/blobdiff - python/mcp/__init__.py
Moved Pin definition back so that __module__ properly rendered by repr(). Fear of...
[hackapet/Adafruit_Blinka.git] / python / mcp / __init__.py
index c29025003703c598939431b24f8836b024e5a280..2ee42c22601ca91c6d0b6c24ecb6fe9fecfef95a 100644 (file)
@@ -6,6 +6,18 @@ class Enum(object):
         as seen with Direction.OUTPUT, Pull.UP
     """
 
+    def __repr__(self):
+        """
+        Assumes instance will be found as attribute of own class.
+        Returns dot-subscripted path to instance
+        (assuming absolute import of containing package)
+        """
+        cls = type(self)
+        for key in dir(cls):
+            if getattr(cls, key) is self:
+                return "{}.{}.{}".format(cls.__module__, cls.__qualname__, key)
+        return repr(self)
+
     @classmethod
     def iteritems(cls):
         """
@@ -18,14 +30,3 @@ class Enum(object):
                 yield (key, val)
 
 
-    def __repr__(self):
-        """
-        Assumes instance will be found as attribute of own class.
-        Returns dot-subscripted path to instance
-        (assuming absolute import of containing package)
-        """
-        cls = type(self)
-        for key in dir(cls):
-            if getattr(cls, key) is self:
-                return "{}.{}.{}".format(cls.__module__, cls.__qualname__, key)
-        return repr(self)
\ No newline at end of file