What do you use as symbols for Python ?

Lonnie Princehouse finite.automaton at gmail.com
Thu Nov 10 15:11:06 EST 2005


I use custom classes and the "is" operator... that way, things don't
get confused with integers, and I have an object where repr(state) will
give me more than an integer.  (the integer approach works well enough
but seems like a case of "I can program C in ANY language!")

opened = type('opened', (object,), {})
closed = type('closed', (object,), {})
error = type('closed', (object,), {})

if thing.state is opened:
  ... 
elif thing.state is error:
  ... etc




More information about the Python-list mailing list