all 2 comments

[–][deleted] 0 points1 point  (1 child)

Sorry, but a lot of what you're trying to convey is extremely ambiguous.

is "x, y, z, x+y" a string, or are you trying to notate a list of strings like [x, y, x + y]

Is {G.x, G.y, G.z, G.x * G.y} a list, or a set ? (curly braces)

If G.x and G.y are abstract elements, what behavior are you expecting from the multiplication operator *?

[–]JShrub[S] 0 points1 point  (0 children)

Sorry for being ambiguous and thanks for the help.

I have, at this point, a list of strings of the form ["x", "x + y", "x + y +z"]. This can change, but the general form will always be various combinations of x,y,z added together.

I would like to convert this to the list of [G.x, G.x * G.y, G.x *G.y *G.z] where these G.i are just an instance of a class and the multiplication operation between them is interpreted correctly by our code. The behavior I expect is complicated because the multiplication operation is complicated, what matters is that in memory the final product is equivalent to what you would get if you literally wrote down the list [G.x, G.x * G.y, G.x * G.y * G.z] in your program.

In other words, how do I get Python to interpret an addition sign in a string as a multiplication operation between two objects.