Ethan Furman added the comment:

+    def __format__(self, *args, **kwargs):
+        return self.__class__._member_type_.__format__(self.value, *args, 
**kwargs)
+

With this in the Enum class all members simply forward formatting to the 
mixed-in type, meaning that IntEnum behaves exactly like int for formatting 
purposes.  Another way of saying that is that the name attribute of an IntEnum 
member will only be used when the !r or !s codes are used.

If we are all good with that, then the question remaining is how should pure 
enums handle formatting?  Should they also go the value route, or should they 
go with the name?

----------

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue18738>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to