Getting all possible value combinations
For an automatic test thing, I have a class with ~15 parameters. I want to automatically generate instances of the class for every possible value combination. For instance, if the class was defined like so:
class meep():
def __init__(self):
self.par1 = 0 # can be in range {0-3}
self.par2 = 1 # can be in range {1-2}
self.par3 = a # can be in range {a-c}
What is the most efficient to get instances of it with all possible value combinations? (IE
inst1=(par1=0,par2=1,par3=a),
in开发者_StackOverflow社区st2=(par1=0,par2=1,par3=b),
inst3=(par1=0,par2=1,par3=c),
inst4=(par1=1,par2=1,par3=a),
inst5=(par1=1,par2=1,par3=b),
inst6=(par1=1,par2=1,par3=c),
etc.)
itertools.product()
精彩评论