P
Pierre Barbier de Reuille
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 = pened
object.state = :closed
object.state = :error
.... but I don't know what to use in Python !
Thanks,
Pierre
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 = pened
object.state = :closed
object.state = :error
.... but I don't know what to use in Python !
Thanks,
Pierre