faqts : Computers : Programming : Languages : Python : Common Problems

+ Search
Add Entry AlertManage Folder Edit Entry Add page to http://del.icio.us/
Did You Find This Entry Useful?

3 of 3 people (100%) answered Yes
Recently 3 of 3 people (100%) answered Yes

Entry

How would one implement (in Python) something similar to C's "enum" type?

Jan 2nd, 2003 08:18
Python Vagabond, Jay Gaikwad, Michael Chermside, http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/67107


http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/67107
Take a look at this recipe by Will Ware in the Python Cookbook.  This 
emulates C's enum datatype.  At the bottom you'll find a second 
approach to the problem.  
BTW, this recipe made it into the hardcopy O'Reilly Python Cookbook.