On Wed, Jul 10, 2013 at 1:24 AM, Aaron Meurer <[email protected]> wrote:
> Yep, strings often (but won't always!) work as input. See
> https://github.com/sympy/sympy/wiki/Idioms-and-Antipatterns#strings-as-input.

Thanks. Yeah, I have learned that from one of my earlier posts to the
forum. In this case it should be fine, I guess.
In fact, I think I made my original query ambiguous: I was really
asking about passing the symbol to be solved for as a string,
*not* the expression.

Is this a better approach:

>>> expr = 'x*2 + 5 + y'
>>> expr=sympify(expr)
>>> for symbol in expr.atoms(Symbol):
...     if str(symbol)=='x':
...          solve(expr, symbol)
...
[-y/2 - 5/2]

So, I look for the symbol I want to solve for and then invoke solve
using the symbol itself, this having to avoid passing a string.

--
http://echorand.me

-- 
You received this message because you are subscribed to the Google Groups 
"sympy" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/sympy.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to