Is there a way to create variable variables in Python for the following specific case: say I have a function that outputs lots of objects (a fixed, but large, number, say 20), like
a1, a2, a3, a4, ..., a20 = f(20),
where a1, a2, a3, ..., a20 are objects.
There have been many questions asked on this topic in SE, where people generally say to use lists or dictionaries. What I don't understand is how to use lists/dictionaries in this specific case.
If I had:
a1 = g(1)
a2 = g(2)
...
I would understand how to do this, but I'm not sure in the above case how to "capture" all the objects into a list without providing explicitly all the variable names.
tuple. You could dofoo = f(20)and then, say,a2would befoo[1].