Re: best way to have enum-like identifiers?

2008-03-12 Thread Pete Forman
[EMAIL PROTECTED] 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,

Re: best way to have enum-like identifiers?

2008-03-12 Thread Peter Otten
[EMAIL PROTECTED] wrote: > 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][func

Re: best way to have enum-like identifiers?

2008-03-11 Thread castironpi
> > [enums snip] > Thus, those names are all bound to unique objects, that won't be > unexpectedly duplicated by some other value. > > > but I'm curious if there's a better way of doing this, some kind of > > enum-like thing or somesuch. > > Please try the 'enum' package in the Cheeseshop: Am I th

Re: best way to have enum-like identifiers?

2008-03-11 Thread Ben Finney
[EMAIL PROTECTED] writes: > Currently I'm just putting this at the top of the file: > > py=1 > funcpre=2 > funcpost=3 > ... Slightly better is: py = object() funcpre = object() funcpost = object() Thus, those names are all bound to unique objects, that won't be unex

best way to have enum-like identifiers?

2008-03-11 Thread 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] ... Curre