[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
[pygame] Python enumerations
There seem to be lots of ways of implementing enumerations in Python.
There's the obvious integer-based way:
APPLE=1
PEACH=2
But in Python its just as easy to define them as strings:
APPLE='APPLE'
PEACH='PEACH'
which makes debugging easier.
Some people even make complicated types, like this one:
http://www.norvig.com/python-iaq.html
(scroll down to "Enumerated Types")
But which way is best? Does anyone have experience with several and want
to recommend something? In particular, does using non-integer
enumerations have a measurable impact on performance?
--
Presumably, we're all fully qualified computer nerds here,
so we are allowed to use "access" as a verb. Be advised,
however, that the practice in common usage drives
English-language purists to scowling fidgets.
- from Sybex's "Perl, CGI and JavaScript", p. 256