Kaydet (Commit) 23bb6f48 authored tarafından Ethan Furman's avatar Ethan Furman

close issue28172: Change all example enum member names to uppercase, per Guido;…

close issue28172: Change all example enum member names to uppercase, per Guido; patch by Chris Angelico.
üst 64a6861b
This diff is collapsed.
...@@ -267,7 +267,7 @@ class EnumMeta(type): ...@@ -267,7 +267,7 @@ class EnumMeta(type):
This method is used both when an enum class is given a value to match This method is used both when an enum class is given a value to match
to an enumeration member (i.e. Color(3)) and for the functional API to an enumeration member (i.e. Color(3)) and for the functional API
(i.e. Color = Enum('Color', names='red green blue')). (i.e. Color = Enum('Color', names='RED GREEN BLUE')).
When used for the functional API: When used for the functional API:
...@@ -517,7 +517,7 @@ class Enum(metaclass=EnumMeta): ...@@ -517,7 +517,7 @@ class Enum(metaclass=EnumMeta):
# without calling this method; this method is called by the metaclass' # without calling this method; this method is called by the metaclass'
# __call__ (i.e. Color(3) ), and by pickle # __call__ (i.e. Color(3) ), and by pickle
if type(value) is cls: if type(value) is cls:
# For lookups like Color(Color.red) # For lookups like Color(Color.RED)
return value return value
# by-value search for a matching enum member # by-value search for a matching enum member
# see if it's in the reverse mapping (for hashable values) # see if it's in the reverse mapping (for hashable values)
......
...@@ -69,9 +69,9 @@ except Exception as exc: ...@@ -69,9 +69,9 @@ except Exception as exc:
# for doctests # for doctests
try: try:
class Fruit(Enum): class Fruit(Enum):
tomato = 1 TOMATO = 1
banana = 2 BANANA = 2
cherry = 3 CHERRY = 3
except Exception: except Exception:
pass pass
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment