best way to have enum-like identifiers?

Pete Forman pete.forman at westerngeco.com
Wed Mar 12 13:35:13 EDT 2008


mh at pixar.com writes:

 > Currently I'm just putting this at the top of the file:
>
 >     py=1
 >     funcpre=2
 >     funcpost=3
 >     ...

That can be done more compactly with

     py, funcpre, funcpost = range(3)

give or take 1.


 > but I'm curious if there's a better way of doing this,
 > some kind of enum-like thing or somesuch.

https://launchpad.net/munepy describes itself as yet another Python
enum implementation.  Its author is Barry Warsaw.
-- 
Pete Forman                -./\.-  Disclaimer: This post is originated
WesternGeco                  -./\.-   by myself and does not represent
pete.forman at westerngeco.com    -./\.-   the opinion of Schlumberger or
http://petef.22web.net           -./\.-   WesternGeco.



More information about the Python-list mailing list