> >>> solve(x**2 == 1/2) > >>> > >>> > as you might notice, this is fully legal Python syntax. Unfortunately > > the semantics is such that sympy has no way to determine what is > > actually going on, this is why they invented all those helper > > functions shown above. >
This is a SymPy special "solution". Nothing in Python prevents from returning a non-boolean from __eq__(): https://docs.python.org/3/reference/datamodel.html#object.__eq__ For example, instead you could use singletons. In fact, every object in symbolic math is a singleton. x**2 is such, (x + 1)**2 - 2*x - 1 - is another, different one. To test structural equality in this approach - you can use "is", instead of "==". _______________________________________________ Python-ideas mailing list -- python-ideas@python.org To unsubscribe send an email to python-ideas-le...@python.org https://mail.python.org/mailman3/lists/python-ideas.python.org/ Message archived at https://mail.python.org/archives/list/python-ideas@python.org/message/KVAV67FODWIJSEDHQSIL55MPS2BVD5X4/ Code of Conduct: http://python.org/psf/codeofconduct/