0

I am working in Blender and Python 3.x.

I would like to use the iterated values of:

list(itertools.product([0,1,2,3], repeat = 3))

>>> [(0, 0, 0), (0, 0, 1), (0, 0, 2), (0, 0, 3), ... (3, 3, 2), (3, 3, 3)]

(64 total products/permutations) And insert their respective values, one set at a time, into the following method:

def vid(h,j,k):
    m = h
    s = j
    b = k

Is it possible to accomplish this with some form of a loop so that, say, (0, 0, 0) can be inserted into (h, j, k), over and over again, until all 64 products/permutations have been inserted?

Apologies if this seems like a silly set of questions or is in any way unclear. Just starting out here on the ol' stack and I am rather stuck on this problem!

1 Answer 1

1

If you want to capture the return values of vid in a iterator, you could use itertools.starmap:

itertools.starmap(vid, itertools.product([0,1,2,3], repeat = 3)))

or (for a list) you could call list on the iterator, or use a list comprehension:

[vid(*tup) for tup in itertools.product([0,1,2,3], repeat = 3)]

If you simply wish to call vid for each tuple, you could use a for-loop:

for tup in itertools.product([0,1,2,3], repeat = 3):
    vid(*tup)
Sign up to request clarification or add additional context in comments.

1 Comment

thank you kindly! i used the last of your suggestions and it works perfectly!

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.