[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

Re: [pygame] Python enumerations



I personally love dictionaries and use them all over the place.  I
haven't run into any problems with that approach, yet.

On 7/18/05, kschnee@xxxxxxxxxx <kschnee@xxxxxxxxxx> wrote:
> >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
> 
> 


-- 
Andrew Ulysses Baker
"failrate"