X-Git-Url: https://git.ayoreis.com/hackapet/Adafruit_Blinka.git/blobdiff_plain/fa129a177261ea51319743fe99910e1ab4e87571..eed35df7a427c7f3e346b6e29ba87b6ca8635561:/python/mcp/__init__.py diff --git a/python/mcp/__init__.py b/python/mcp/__init__.py index c290250..2ee42c2 100644 --- a/python/mcp/__init__.py +++ b/python/mcp/__init__.py @@ -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