import itertools
def GenerateAll(source, rep):
for comb in itertools.combinations(range(len(source)), len(rep)):
s = list(source)
for (i, j) in enumerate(comb):
s[j] = rep[i];
yield "".join(s)
#print(list(GenerateAll("0101010101", "aXZ")))
z =(list(GenerateAll("0101010101", "aXZ")))
if z == 'aXZ1010101':print(z)