summaryrefslogtreecommitdiffstats
path: root/Doc/library/enum.rst
diff options
context:
space:
mode:
authorEthan Furman <ethan@stoneleaf.us>2013-09-01 02:17:41 (GMT)
committerEthan Furman <ethan@stoneleaf.us>2013-09-01 02:17:41 (GMT)
commitec15a826ce6a49e4b1ba184517da9b739cb3db8f (patch)
tree4d8ecd5aa3cd2cefa65b07f35a1ac4881c7353f2 /Doc/library/enum.rst
parent34567ec94b17e159fac8424559698f48a713991f (diff)
downloadcpython-ec15a826ce6a49e4b1ba184517da9b739cb3db8f.zip
cpython-ec15a826ce6a49e4b1ba184517da9b739cb3db8f.tar.gz
cpython-ec15a826ce6a49e4b1ba184517da9b739cb3db8f.tar.bz2
Close #18738: Route __format__ calls to mixed-in type for mixed Enums (such as IntEnum).
Diffstat (limited to 'Doc/library/enum.rst')
-rw-r--r--Doc/library/enum.rst6
1 files changed, 6 insertions, 0 deletions
diff --git a/Doc/library/enum.rst b/Doc/library/enum.rst
index 6864705..14dcfa7 100644
--- a/Doc/library/enum.rst
+++ b/Doc/library/enum.rst
@@ -463,6 +463,12 @@ Some rules:
3. When another data type is mixed in, the :attr:`value` attribute is *not the
same* as the enum member itself, although it is equivalant and will compare
equal.
+4. %-style formatting: `%s` and `%r` call :class:`Enum`'s :meth:`__str__` and
+ :meth:`__repr__` respectively; other codes (such as `%i` or `%h` for
+ IntEnum) treat the enum member as its mixed-in type.
+5. :class:`str`.:meth:`__format__` (or :func:`format`) will use the mixed-in
+ type's :meth:`__format__`. If the :class:`Enum`'s :func:`str` or
+ :func:`repr` is desired use the `!s` or `!r` :class:`str` format codes.
Interesting examples