On Mar 16, 7:37 pm, Vinzent Steinberg
<vinzent.steinb...@googlemail.com> wrote:
> On 15 Mrz., 19:37, smichr <smi...@gmail.com> wrote:
>
> > >>> exec("%s=symbols('%s')" % (("n,P,R,D,m,f,a,C,L",)*2))
>
> Why don't you just use
>
> >>> var("n,P,R,D,m,f,a,C,L")
>

That exec statement is what I used in a function to generate an
executable string that can be used to create variables from a sympy
expression. Here's what my work session looked like:

>>> from my import Var
>>> e = Var('(D*f + R*a*n - C*R*m - D*P*m - P*R*m + D*L*a*n - C*D*L*m - 
>>> D*L*P*m)/(R + D*L) ')
>>> e
"n,P,R,D,m,f,a,C,L=symbols('n,P,R,D,m,f,a,C,L')"
>>> exec(e)
>>> eq=(D*f + R*a*n - C*R*m - D*P*m - P*R*m + D*L*a*n - C*D*L*m - D*L*P*m)/(R + 
>>> D*L)
>>> n,d = eq.as_numer_denom()
>>> s = eq.atoms(Symbol)
>>> w,r = div(Poly(n,*s),Poly(d,*s))
>>> w+r/d
a*n + (D*f - D*P*m)/(R + D*L) - C*m - P*m

I didn't use a var() statement because I thought it didn't take a
assumptions argument, but in writing this response, I see that it
does!

>>> var('x, y', commutative=False)
(x, y)
>>> x*y+y*x
x*y + y*x

So I guess the only difference is that in the interactive environment,
var() echoes the variables while Symbol and symbols does not. (And
symbols will parse single characters from a string like 'abcxyz'.)

-- 
You received this message because you are subscribed to the Google Groups 
"sympy" group.
To post to this group, send email to sy...@googlegroups.com.
To unsubscribe from this group, send email to 
sympy+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/sympy?hl=en.

Reply via email to