[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.
How about dictionaries?
fruit = {"apple":42,"peach":3141592}
These give you a flexible way of storing different kinds of information
within a single class. For instance, I once used a class to store my
program's interpretation of an English sentence. The class had to have a
variable for every possible "slot" in the sentence, like "subject noun"
and "verb," and couldn't use varied grammatical structures. I switched to
dictionaries and now have a complicated thing-that's-not-an-object that
can represent many different groupings of words and ideas.
Kris