best way to have enum-like identifiers?

mh at pixar.com mh at pixar.com
Wed Mar 12 00:52:57 EDT 2008


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



More information about the Python-list mailing list