I'm writing a Math equation solver in python (for fun). The first design that came to my mind:
Expression: base class for every item in an equation (maybe bad name).
Expression: two expressions with a sign.
Expression + Expressionshould provide a
BinaryExpression, I do this through overriding the
this is sort of circular dependency, which me and python both hates.
class Expression(object): def __add__(self, other): return BinaryExpresison(self, OP.ADD, other) class BinaryExpress(Expression): def __init__(self, op, other): pass # super and staff
How would you do it?