Thursday, February 2, 2012

Re: Newbie django/python with C++ background wants enums

I'm straying a bit off-topic here, but I forgot to mention that other
way I've seen people do 'enum' in Python is:

>>> class Colors(object):
... RED, GREEN, BLUE = range(3)
...
>>> c = Colors()
>>> c.RED
0
>>> c.BLUE
2
>>> c.GREEN
1

Not sure this helps much in this particular case though.

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to django-users+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.

No comments:

Post a Comment