I've searched and couldn't find a direct answer for my question, so apologies if this has already been posted/answered before. I'm working in python and i need to pass expressions that contain variables, but i don't want them to be immediately evaluated.
For example:
r = x*y
I want the program to remember that in order to calculate r, it needs to multiply x and y instead of explicitly calculating it at the time. I've tried using:
x = None
y = None
r = x*y
But this doesn't allow operations on the variables. I've managed it using strings and then using "eval" but its not a very elegant solution, and its also painfully slow. Is there a better way of doing this?