There are an infinite number of possible operations on two variables. In fact, there are an uncountable number of functions on two variables (or one variable for that matter). This means that it is provably impossible to recursively enumerate them.
It is, however, possible to pick some enumerable subset of all possible functions and then iterate over those. For example, the set of integer-coefficient polynomials of two variables. If you have a set in mind, we can help you enumerate them.
9.9. operator — Standard operators as functions shows a list of the functions in import operator that will name functions that can be used in place of various operators (such as add). Create a list containing these operator functions and loop through the list. Note that you must be careful to treat the one argument and two argument functions seperately so as to avoid a fatal error when you call them.
The operator module exports a set of efficient functions corresponding
to the intrinsic operators of Python. For example, operator.add(x, y)
is equivalent to the expression x+y. The function names are those used
for special class methods; variants without leading and trailing __
are also provided for convenience.
The functions fall into categories that perform object comparisons,
logical operations, mathematical operations, sequence operations, and
abstract type tests.
Asked in February 2016Viewed 3,863 timesVoted 6Answered 2 times