Posted By

miceno on 12/01/14


Tagged


Versions (?)

Who likes this?

1 person have marked this snippet as a favorite

hyuna917


Enumeration in python


 / Published in: Python
 

Simple ways to get enumerations in python.

  1. >>> Status = namedtuple('Status', 'open pending closed')._make(range(3))
  2. >>> Status.open, Status.pending, Status.closed
  3. (0, 1, 2)
  4.  
  5.  
  6. >>> class Status:
  7. open, pending, closed = range(3)
  8. >>> Status.open, Status.pending, Status.closed
  9. (0, 1, 2)

Report this snippet  

You need to login to post a comment.