class IterableNumber:

    def __init__(self, digits):
        self.digits = digits
self.zero_indices = np.where(self.digits == 0)[0]
self.length = len(self.zero_indices)

def __iter__(self):
    for x in product(list(range(10)), repeat=self.length):
        self.digits[self.zero_indices] = np.array(x)
yield self.digits
Iterator for variable number of nested loops