@@ -141,9 +141,8 @@ Module Contents
141
141
:func: `global_enum `
142
142
143
143
Modify the :class: `str() <str> ` and :func: `repr ` of an enum
144
- to show its members as belonging to the module instead of its class.
145
- Should only be used if the enum members will be exported to the
146
- module global namespace.
144
+ to show its members as belonging to the module instead of its class,
145
+ and export the enum members to the global namespace.
147
146
148
147
:func: `show_flag_values `
149
148
@@ -170,6 +169,27 @@ Data Types
170
169
final *enum *, as well as creating the enum members, properly handling
171
170
duplicates, providing iteration over the enum class, etc.
172
171
172
+ .. method :: EnumType.__call__(cls, value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)
173
+
174
+ This method is called in two different ways:
175
+
176
+ * to look up an existing member:
177
+
178
+ :cls: The enum class being called.
179
+ :value: The value to lookup.
180
+
181
+ * to use the ``cls `` enum to create a new enum (only if the existing enum
182
+ does not have any members):
183
+
184
+ :cls: The enum class being called.
185
+ :value: The name of the new Enum to create.
186
+ :names: The names/values of the members for the new Enum.
187
+ :module: The name of the module the new Enum is created in.
188
+ :qualname: The actual location in the module where this Enum can be found.
189
+ :type: A mix-in type for the new Enum.
190
+ :start: The first integer value for the Enum (used by :class: `auto `).
191
+ :boundary: How to handle out-of-range values from bit operations (:class: `Flag ` only).
192
+
173
193
.. method :: EnumType.__contains__(cls, member)
174
194
175
195
Returns ``True `` if member belongs to the ``cls ``::
@@ -262,26 +282,6 @@ Data Types
262
282
names will also be removed from the completed enumeration. See
263
283
:ref: `TimePeriod <enum-time-period >` for an example.
264
284
265
- .. method :: Enum.__call__(cls, value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)
266
-
267
- This method is called in two different ways:
268
-
269
- * to look up an existing member:
270
-
271
- :cls: The enum class being called.
272
- :value: The value to lookup.
273
-
274
- * to use the ``cls `` enum to create a new enum:
275
-
276
- :cls: The enum class being called.
277
- :value: The name of the new Enum to create.
278
- :names: The names/values of the members for the new Enum.
279
- :module: The name of the module the new Enum is created in.
280
- :qualname: The actual location in the module where this Enum can be found.
281
- :type: A mix-in type for the new Enum.
282
- :start: The first integer value for the Enum (used by :class: `auto `).
283
- :boundary: How to handle out-of-range values from bit operations (:class: `Flag ` only).
284
-
285
285
.. method :: Enum.__dir__(self)
286
286
287
287
Returns ``['__class__', '__doc__', '__module__', 'name', 'value'] `` and
@@ -722,7 +722,6 @@ Data Types
722
722
.. attribute :: EJECT
723
723
724
724
Out-of-range values lose their *Flag * membership and revert to :class: `int `.
725
- This is the default for :class: `IntFlag `::
726
725
727
726
>>> from enum import Flag, EJECT , auto
728
727
>>> class EjectFlag (Flag , boundary = EJECT ):
@@ -734,8 +733,8 @@ Data Types
734
733
735
734
.. attribute :: KEEP
736
735
737
- Out-of-range values are kept, and the *Flag * membership is kept. This is
738
- used for some stdlib flags ::
736
+ Out-of-range values are kept, and the *Flag * membership is kept.
737
+ This is the default for :class: ` IntFlag ` ::
739
738
740
739
>>> from enum import Flag, KEEP, auto
741
740
>>> class KeepFlag(Flag, boundary=KEEP):
0 commit comments