sage: sage_eval?
<snip>
Obtain a Sage object from the input string by evaluating it using
Sage. This means calling eval after preparsing and with globals
equal to everything included in the scope of "from sage.all import
*".).
INPUT:
* "source" - a string or object with a _sage_ method
y=3
isn't a "thing", so you can't sage_eval
it. Maybe you want this, though, also from the documentation.
You can also specify the object to evaluate as a tuple. A 2-tuple
is assumed to be a pair of a command sequence and an expression; a
3-tuple is assumed to be a triple of a command sequence, an
expression, and a dictionary holding local variables. (In this
case, the given dictionary will not be modified by assignments in
the commands.)
::
sage: sage_eval(('f(x) = x^2', 'f(3)'))
9
So you would have
sage: sage_eval(('y=3','y'))
3
What's wrong with a simple assignment y=3, why do you need sage-eval ?
I don't understand what is going on. I just started a brand-new Sage session, typed this one-liner in, and got `3`. Is there anything else you did? There shouldn't be a `y` coming out at all.
@kcrisman 'y' is an input, not an output.
I wanted to create function that solve equation and determine which parameter to be evaluated. For example at the input Python dictionary: {'F_zat':300, 'sigma_t':250, 'd3':'?'} Function should to determine d3. eq(F_zat, sigma_t, d3) = ... is also function input.... Unfortunately english isn't my native language and it's difficult to me to explain my task in english. But today I have solved this task so this question is closed. Thanks everybody for the help!
@Bétréma: Ah, that was not clear from the formatting; I thought that was the whole output. Looks like `sage_eval`, presumably intentionally, doesn't alter the globals.