From 6db1fd5fb8b2287cd4713c95f0df451e375c8853 Mon Sep 17 00:00:00 2001 From: Ethan Furman Date: Thu, 17 Sep 2015 21:49:12 -0700 Subject: Close issue24840: Enum._value_ is queried for bool(); original patch by Mike Lundy --- Lib/enum.py | 3 +++ 1 file changed, 3 insertions(+) (limited to 'Lib/enum.py') 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 -- cgit v1.2.1