equivalent of enum?

Alan Daniels daniels at mindspring.com
Sun Sep 12 22:20:46 EDT 1999


On Fri, 10 Sep 1999 00:18:24 GMT, the infinitely wise Doug Hellmann
(doughellmann at home.com) spoke forth to us, saying...

[snip...]
>	one, two, three = range(3)
>	print one, two, three

This is a handy little trick (thanks for posting it!), and not to be
picky, but the indexing will start at zero instead of one, which could
trip up people new to Python. So this would be better as:

	zero, one, two = range(3)

Or, maybe:

	one, two, three = range(1, 4)

Also, just as a matter of style, I use all CAPS when the number I'm
defining is meant to be a constant. Using ranges is sure going to beat
naming all the enum values by hand, though. :=)

-- 
=======================
Alan Daniels
daniels at mindspring.com
daniels at cc.gatech.edu




More information about the Python-list mailing list