summaryrefslogtreecommitdiff
path: root/Lib/enum.py
diff options
context:
space:
mode:
authorEthan Furman <ethan@stoneleaf.us>2015-09-17 21:49:12 -0700
committerEthan Furman <ethan@stoneleaf.us>2015-09-17 21:49:12 -0700
commitb437f937dcddac9b8790beefab5ccc60d2c6584c (patch)
tree8a10853d3db6a8897eedff21e6e0840ac1e2edae /Lib/enum.py
parent175dd603f559ea357152cba58bc0be714ea5787d (diff)
downloadcpython-b437f937dcddac9b8790beefab5ccc60d2c6584c.tar.gz
Close issue24840: Enum._value_ is queried for bool(); original patch by Mike Lundy
Diffstat (limited to 'Lib/enum.py')
-rw-r--r--Lib/enum.py3
1 files changed, 3 insertions, 0 deletions
diff --git a/Lib/enum.py b/Lib/enum.py
index c28f3452a7..616b2eac15 100644
--- a/Lib/enum.py
+++ b/Lib/enum.py
@@ -476,6 +476,9 @@ class Enum(metaclass=EnumMeta):
def __str__(self):
return "%s.%s" % (self.__class__.__name__, self._name_)
+ def __bool__(self):
+ return bool(self._value_)
+
def __dir__(self):
added_behavior = [
m