By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
443,399 Members | 886 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 443,399 IT Pros & Developers. It's quick & easy.

best way to have enum-like identifiers?

P: n/a
mh
I currently have a 2-dim hash, indexed by two strings:

template['py']['funcpre']
template['py']['funcpost']
...

but I would prefer to have these indexed by constants of
some kind, since this seems a bit more natural:

template[py][funcpre]
template[py][funcpost]
...

Currently I'm just putting this at the top of the file:

py=1
funcpre=2
funcpost=3
...

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

Many TIA!
Mark

--
Mark Harrison
Pixar Animation Studios
Mar 12 '08 #1
Share this Question
Share on Google+
1 Reply


P: n/a
mh@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
pe*********@westerngeco.com -./\.- the opinion of Schlumberger or
http://petef.22web.net -./\.- WesternGeco.
Mar 12 '08 #2

This discussion thread is closed

Replies have been disabled for this discussion.