What do you use as symbols for Python ?
Pierre Barbier de Reuille
pierre.barbier at cirad.fr
Thu Nov 10 02:37:19 EST 2005
When you need some symbols in your program, what do you use in Python ?
For example, an object get a state. This state is more readable if
expressed as a symbols, for example "opened", "closed", "error".
Typically, in C or C++, I would use an enum for that:
enum OBJECT_STATE
{
opened, closed, error
}
In CAML or Haskell I would use the union types:
type ObjectState = Opened | Closed | Error
In Ruby I would use the symbols :
object.state = :opened
object.state = :closed
object.state = :error
... but I don't know what to use in Python !
Thanks,
Pierre
More information about the Python-list
mailing list