python-constraint

Thepython-constraint module offers efficient solvers for Constraint Satisfaction Problems (CSPs) over finite domains in an accessible package.
All it takes is a few lines of code:
>>>fromconstraintimport*>>>problem=Problem()>>>problem.addVariable("a",[1,2])>>>problem.addVariable("b",[3,4])>>>problem.getSolutions()[{'a': 2, 'b': 4}, {'a': 2, 'b': 3}, {'a': 1, 'b': 4}, {'a': 1, 'b': 3}]>>>problem.addConstraint(lambdaa,b:a*2==b,("a","b"))>>>problem.getSolutions()[{'a': 2, 'b': 4}]

Indices and tables