Enumming
Will Ware
wware at world.std.com
Mon Aug 21 17:17:51 EDT 2000
Larry Whitley (ldw at us.ibm.com) wrote:
> Here's my class of enums:
> class E:
> a,b,c,d,e = range( 5 )
I have seen (and a few times recommended to others) the simpler
scheme of doing this in the global namespace, just typing:
a,b,c,d,e = range( 5 )
But I see that it's better to wrap it in a class as you've done,
to avoid the possibility of namespace collisions. Also the class
name can be used to meaningfully describe the enum values as a
group. So Volkswagen.BEETLE would be different from Insect.BEETLE.
Worth a little extra typing to avoid namespace clutter and gain
clarity.
--
# - - - - - - - - - - - - - - - - - - - - - - - -
# Resistance is futile. Capacitance is efficacious.
# Will Ware email: wware @ world.std.com
More information about the Python-list
mailing list