Is its possible to define an algebra for string objects? For example:
Are there built-in functions that could do that? Is the creation of a class structure necessary?
You could use SymPy
to define symbolic variables for this type of algebra.
>>> from sympy import *
>>> apple = symbols('apple')
>>> orange = symbols('orange')
>>> apple + apple
2*apple
>>> apple + orange
apple + orange
>>> apple + 3.5 * apple
4.5*apple