I am looking for a method to dive into a list and directly access its elements. For example, the following is the normal way of getting the Cartesian product of for sets.
>>> list(itertools.product((0,1), (0,1),(0,1),(0,1)))
[(0, 0, 0, 0), (0, 0, 0, 1), (0, 0, 1, 0), (0, 0, 1, 1), (0, 1, 0, 0), (0, 1, 0, 1), (0, 1, 1, 0), (0, 1, 1, 1), (1, 0, 0, 0), (1, 0, 0, 1), (1, 0, 1, 0), (1, 0, 1, 1), (1, 1, 0, 0), (1, 1, 0, 1), (1, 1, 1, 0), (1, 1, 1, 1)]
But in this case the four sets are identical, and it soon gets boring and tiresome to have to type it over and over again, which makes one think of doing this instead:
>>> list(itertools.product([(0,1)]*4)
But of course it won't work, since the itertools.product function will see it as one set instead of four sets. So, the question is, is there a way to do this:
>>> list(itertools.product(delist([(0,1)]*4))