I need a lot of nested loops and want to use itertool's product. The following does what I want:
for v9,v8,v7,v6,v5,v4,v3,v2,v1 in itertools.product([0,1],[0,1],[0,1],[0,1],[0,1],[0,1],[0,1],[0,1],[0,1]):
#do something with v1,v2,v3,v4,v5,v6,v7,v8,v9
However, it is far from elegant. Is there a way to write it in a neater way? It would be nice to "outsource" the arguments of the itertools.product in some way such that one can adapt it better. I mean something like
lim = 10
var = [f"v{i}" for i in range(1,lim)]
kar = [[0,1] for _ in range(1,lim)]
for var in itertools.product(kar):
#do something
I'm fully aware that this cannot work in various dimensions, I just wrote it to make clear what I have in mind.