Referring to a list

Sean Berry sean_berry at
Fri Jun 25 22:42:38 CEST 2004

I have a function like this:

final_list = []

def doSomething():
    for item in starting_list = []:
        Do all sorts of stuff... about 150 lines of processing.
        Lots of conditional statements for appending to the final_list.
            So I have lots of final_list.append( results ) statements.

I wanted to single out a few cases and have
them append to a different list.

The way I would "normally" do something like this would be to have
all of the .append() statements in another function like this

def addToList( listName, otherInfo )
    do something with otherInfo.
    then listName.append( results )

But, in this case, by the time I get to this point there
are too many variables to pass (something like 60).

So, what I want to do is use some kind of name reference
for the list I want to use.

final_list = []
secondary_list = []

def DoSomething():
    if (condition is met):
        list_i_am_referring_to = final_list
        list_i_am_referring_to = secondary_list

then I can do everything using the list_i_am_referring_to.

Is this possible???

Sorry about my poor, and lengthy explanation.
Thanks for any help.

More information about the Python-list mailing list