0

I want to create a list of procedures, but when I use this

Characters=[Percy(),Annabeth(),Leo(),Chuck(),Sarah()]

each of these procedures brings up a tkinter window with a quote from that character, but if I run the code, instead of treating it like a list, python executes each procedure in order, am I doing this completely wrong? Or is there just no way to create a list of procedures. Note: It needs to be in a list because I need to be able to access a random position in it

4

1 回答 1

8

you probably want:

Characters = [Percy, Annabeth, Leo, Chuck, Sarah]

Now to call Percy, you do:

percy_result = Characters[0]()

As you have it, you're storing a list of results of those procedures instead of storing the procedures themselves.

于 2012-10-22T03:20:58.037 回答