I need to create a list of named lists, so that I can iterate over them. This works, but I'm wondering if there isn't a better way.
terms = []; usedfors = []; broaders = []; narrowers = []
termlist = [terms, usedfors, broaders, narrowers]
The reason for doing it this way is that I have a function do_some_list_operation(l) and I want to do something like
for i in termlist:
do_some_list_operation(i)
rather than
do_some_list_operation(terms)
do_some_list_operation(usedfors)
do_some_list_operation(broaders)
do_some_list_operation(narrowers)
I've been searching for 'how to build list of named lists' to no avail.
dictperhaps?forloop looks good to me as is at the moment. unless your termlist is strings liketermlist = ["terms", "usedfors", "broaders", "narrowers"]mylist[0],mylist[1], etc. I chose list because they need to be an ordered collection of strings. I'd usedictorOrderedDictfor key-value pairs.