File tree Expand file tree Collapse file tree 1 file changed +18
-0
lines changed Expand file tree Collapse file tree 1 file changed +18
-0
lines changed Original file line number Diff line number Diff line change @@ -430,6 +430,19 @@ Note: if your enumeration defines :meth:`__new__` and/or :meth:`__init__` then
430
430
any value(s) given to the enum member will be passed into those methods.
431
431
See `Planet `_ for an example.
432
432
433
+ .. note ::
434
+
435
+ The :meth: `__new__ ` method, if defined, is used during creation of the Enum
436
+ members; it is then replaced by Enum's :meth: `__new__ ` which is used after
437
+ class creation for lookup of existing members.
438
+
439
+ .. warning ::
440
+
441
+ *Do not * call ``super().__new__() ``, as the lookup-only ``__new__ `` is the one
442
+ that is found; instead, use the data type directly -- e.g.::
443
+
444
+ obj = int.__new__(cls, value)
445
+
433
446
434
447
Restricted Enum subclassing
435
448
---------------------------
@@ -927,6 +940,11 @@ want one of them to be the value::
927
940
>>> print(Coordinate(3))
928
941
Coordinate.VY
929
942
943
+ .. warning ::
944
+
945
+ *Do not * call ``super().__new__() ``, as the lookup-only ``__new__ `` is the one
946
+ that is found; instead, use the data type directly.
947
+
930
948
931
949
Finer Points
932
950
^^^^^^^^^^^^
You can’t perform that action at this time.
0 commit comments