I'm a newbie to python, writing a python script to keep track of notation in a math paper. If the paper defines values (numbers, groups, etc.) with names "A", "B", "C", "D", I want to easily be able to keep track of equalities between them, so that if I write value("A") = value("B")
and value("B") = value("C")
then value("A") == value("C")
evaluates to True
and value("A") == value("D")
evaluates to False
.
Answers to this question seemed promising, but when I define a class value
with an equivalence checking function, it won't let me write value("A") = value("B"). I know I could define a graph with edges (value("A"), value("B")) for each equality, then find its connected components, but this seems complicated and inelegant. Is there a better solution?