Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 9026262

Browse files
committed
fixed examples to work with changed attribute names
1 parent 20ac14f commit 9026262

1 file changed

Lines changed: 5 additions & 5 deletions

File tree

Doc/library/enum.rst

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -483,7 +483,7 @@ Avoids having to specify the value for each enumeration member::
483483
... def __new__(cls):
484484
... value = len(cls.__members__) + 1
485485
... obj = object.__new__(cls)
486-
... obj._value = value
486+
... obj._value_ = value
487487
... return obj
488488
...
489489
>>> class Color(AutoNumber):
@@ -505,19 +505,19 @@ enumerations)::
505505
>>> class OrderedEnum(Enum):
506506
... def __ge__(self, other):
507507
... if self.__class__ is other.__class__:
508-
... return self._value >= other._value
508+
... return self.value >= other.value
509509
... return NotImplemented
510510
... def __gt__(self, other):
511511
... if self.__class__ is other.__class__:
512-
... return self._value > other._value
512+
... return self.value > other.value
513513
... return NotImplemented
514514
... def __le__(self, other):
515515
... if self.__class__ is other.__class__:
516-
... return self._value <= other._value
516+
... return self.value <= other.value
517517
... return NotImplemented
518518
... def __lt__(self, other):
519519
... if self.__class__ is other.__class__:
520-
... return self._value < other._value
520+
... return self.value < other.value
521521
... return NotImplemented
522522
...
523523
>>> class Grade(OrderedEnum):

0 commit comments

Comments
 (0)