(self, formula, args, **kwargs)
return res
From (x + 1) * (y - 1) * p * (m + (7 - p))
           Create [[x, 1], [y, -1*1], [p], [m, 7, -1*p]]
           Compute the cartesian product (itertools.product)
From (x + 1) * (y - 1) * p * (m + (7 - p))
           Create [[x, 1], [y, -1*1], [p], [m, 7, -1*p]]
           Compute the cartesian product (itertools.product)
From ( x + 1 ) * ( y - 1 ) * p * ( m + ( 7 - p )) Create [[ x 1 ] [ y - 1 * 1 ] [ p ] [ m 7 - 1 * p ]] Compute the cartesian product ( itertools . product )
def walk_times(self, formula, args, **kwargs):
        """
           From (x + 1) * (y - 1) * p * (m + (7 - p))
           Create [[x, 1], [y, -1*1], [p], [m, 7, -1*p]]
           Compute the cartesian product (itertools.product)

        """
        # Check if there is at least one Plus to distribute over,
        # otherwise we are done. Note that walk_minus rewrites the
        # minus as a plus
        if not any(x.is_plus() for x in args):
            return self.Times(*args)

        # Create list of additions
        flat_args = []
        for a in args:
            # Flattening
            if a.is_plus():
                flat_args.append(a.args())
            else:
                flat_args.append([a])
        res = self.Plus(self.Times(p) for p in product(*flat_args))
        return res
def walk_times ( self , formula , args , * * kwargs ) : # Check if there is at least one Plus to distribute over, # otherwise we are done. Note that walk_minus rewrites the # minus as a plus if not any ( x . is_plus ( ) for x in args ) : return self . Times ( * args ) # Create list of additions flat_args = [ ] for a in args : # Flattening if a . is_plus ( ) : flat_args . append ( a . args ( ) ) else : flat_args . append ( [ a ] ) res = self . Plus ( self . Times ( p ) for p in product ( * flat_args ) ) return res