On Mon, Dec 22, 2008 at 6:12 AM, Timothy Clemans
<[email protected]> wrote:
>
> sage: sage0("var('a b c')")
> (a, b, c)
> sage: sage0("a = b/c")
>
> b
That's not quite right as it creates 'a' in a different session.
There are a few variations depending on exactly what you want to do.
If you want to assign something to 'a', then you don't need to declare
it as a variable first. You can use the globals() dictionary to
insert it into the namespace:
sage: b, c = var('b, c')
sage: s = "a"
sage: globs = globals()
sage: globs[s] = b/c
sage: a
b/c
If you just have "b/c" as a string and don't know ahead of time what
variables are going to be in it, the you can do something like this:
sage: s = "b/c"
sage: a = SR(s)
sage: a
b/c
SR is the parent object for symbolic expressions. When you write
SR(s) (or in fact P(s) where P is any parent), it means "try to make
an element of this parent".
--Mike
--~--~---------~--~----~------------~-------~--~----~
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/sage-support
URLs: http://www.sagemath.org
-~----------~----~----~----~------~----~------~--~---