(python)
so I have the following values & lists:
name = colour
size = ['256', '512', '1024', '2048', '4096', '8192', '16384', '32768']
depth = ['8', '16', '32']
scalar = ['False', 'True']
alpha = ['False', 'True']
colour = app.Color(0.5)
Run Code Online (Sandbox Code Playgroud)
and I want to iterate over these to produce every possible combination with the following structure:
createChannel(ChannelInfo(name, size, depth, scalar, alpha, colour))
Run Code Online (Sandbox Code Playgroud)
so the values for name, size, etc must stay in the same place, but they must iterate over all possible combinations of size, depth, etc..
i.e. I want to return something like this:
createChannel(ChannelInfo('colour', 256, 8, False, True, 0.5)
createChannel(ChannelInfo('colour1', 256, 8, False, False, 0.5)
createChannel(ChannelInfo('colour2', 256, 16, False, False, 0.5)
Run Code Online (Sandbox Code Playgroud)
...etc...there are 96 combinations
Thanks
import itertools
for iter in itertools.product(size, depth, scalar, alpha):
print iter # prints 96 four-element tuples
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
1030 次 |
| 最近记录: |