This question, though specific in nature, can be abstracted to a general question about Python.
Imagine there is a function that takes in a few parameters. This list of parameters is of variable length; however, the types of the given parameters are not variable. The parameters come in groups of three, and the first and second are lists of floats and the third is a string. Then it repeats. So, in a way, the parameters are not of variable length, it's restricted to multiples of 3.
The types can be anything, those are just the ones specific to my problem. I have a matplotlib plot function that looks like this in the docs:
a.plot(x1, y1, 'g^', x2, y2, 'g-',...)
As you can see, number of groups of three can be however long you want.
I have a list of lists that contains all of my x values (x1, x2, x3, ...) and a list of lists that contain all of my y values (y1, y2, y3,...). Not knowing how long those lists are (they are always equal in length to each other, though), and assuming I can have some dictionary that maps certain indexes to certain strings (for the string parameter), how can I pass indexes from variables length list of lists to this function.
Ideally, I guess it would look something like this is pseudo-code:
for element in list_of_lists:
myFunction(lists_of_lists[element])
Except that this code would just execute the myFunction for all the elements in the list_of_lists. Instead, I want one long list of parameters and only execute the function once. I also feel like this problem is interested for Python as a whole, not just my specific issue. Thanks in advance!
[(x1, y1, 'g^'), (x2, y2, 'g-')], etc. If the arguments only make sense when all three are provided together, use a data structure that keeps them together. To actually create such tuples from your list of lists, thezipbuiltin is probably the starting point, although your dictionary of string indices will complicate things.