ProAnswers.org

Best way to implement the equivalent of an enum in Python?

What’s the best way to implement the equivalent of an enum in Python?

Python doesn't have an equivalent but you can implement your own.



I am trying this:




	
		
			class Animal: 
			    DOG=1 
			    CAT=2 
			 
			x = Animal.DOG