can anyone suggest a simple method to define an enum in python.

as some examples floating on net, i used

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


but it doesn't seem to be working...

I got a solution on one of the forums...

class Materials:
Shaded, Shiny, Transparent, Matte = range(4)

>>> print Materials.Matte
3

If U have better ideas, do suggest pls....

can anyone suggest a simple method to define an enum in python.

as some examples floating on net, i used

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


but it doesn't seem to be working...

This works ...

class Animal:
    DOG = 1
    CAT = 2

print Animal.DOG  # 1

Why that didnt worked? How come? :)

@ ultimatebuster
yeah.....i am going for a dictionary instead. thanx...