summaryrefslogtreecommitdiffstats
path: root/Lib/enum.py
diff options
context:
space:
mode:
Diffstat (limited to 'Lib/enum.py')
-rw-r--r--Lib/enum.py11
1 files changed, 10 insertions, 1 deletions
diff --git a/Lib/enum.py b/Lib/enum.py
index c28f345..8d04e2d 100644
--- a/Lib/enum.py
+++ b/Lib/enum.py
@@ -1,7 +1,13 @@
import sys
-from collections import OrderedDict
from types import MappingProxyType, DynamicClassAttribute
+# try _collections first to reduce startup cost
+try:
+ from _collections import OrderedDict
+except ImportError:
+ from collections import OrderedDict
+
+
__all__ = ['Enum', 'IntEnum', 'unique']
@@ -476,6 +482,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