@@ -29,7 +29,7 @@ def __new__(cls, name=None, names=None):
2929 if name and names :
3030 # Support Functional API: Enum("Name", {"KEY1": VALUE1, "KEY2": VALUE2, ..})
3131 # Dynamically create: class <name>
32- new_cls = type (name , (cls ,), {"_inited " : True })
32+ new_cls = type (name , (cls ,), {"_i " : True }) # _inited
3333 for k , v in names .items ():
3434 setattr (new_cls , k , _make_enum (v , k , name ))
3535 return super ().__new__ (new_cls )
@@ -41,7 +41,7 @@ def __new__(cls, name=None, names=None):
4141 return super ().__new__ (cls )
4242
4343 def __init__ (self , name = None , names = None ):
44- if "_inited " not in self .__class__ .__dict__ :
44+ if "_i " not in self .__class__ .__dict__ :
4545 self .list ()
4646
4747 @classmethod
@@ -57,12 +57,12 @@ def __iter__(cls):
5757
5858 @classmethod
5959 def list (cls ):
60- if "_inited " not in cls .__dict__ :
60+ if "_i " not in cls .__dict__ :
6161 # Copy dict.items() to avoid RuntimeError when changing the dictionary
6262 for k , v in list (cls .__dict__ .items ()):
6363 if not k .startswith ("_" ) and not callable (v ):
6464 setattr (cls , k , _make_enum (v , k , cls .__name__ ))
65- cls ._inited = True
65+ cls ._i = True
6666 return [
6767 m for k in dir (cls ) if not k .startswith ("_" ) and hasattr (m := getattr (cls , k ), "name" )
6868 ]
@@ -81,7 +81,7 @@ def __call__(self, v):
8181 return self ._lookup (v )
8282
8383 def __setattr__ (self , k , v ):
84- if "_inited " in self .__class__ .__dict__ :
84+ if "_i " in self .__class__ .__dict__ :
8585 raise AttributeError (f"Enum '{ self .__class__ .__name__ } ' is immutable" )
8686 super ().__setattr__ (k , v )
8787
@@ -109,7 +109,7 @@ class Color(Enum):
109109 # Basic access
110110 print (f"RED: repr={ repr (Color .RED )} , type={ type (Color .RED )} , { Color (1 ).name } " )
111111 print (f"RED: name={ Color .RED .name } , value={ Color .RED .value } , str={ str (Color .RED )} , call={ Color .RED ()} " )
112- assert Color (1 ).value == 1
112+ assert Color (1 ).value == 1
113113 assert Color .BLUE .value >= Color .GREEN .value
114114
115115 print ("Color.list():" , Color .list ())
0 commit comments