You can do it like this:

In [7]: setupstr='LI(OAMHolo(OAMHolo(XX,e,6),f,2),a,f)'

In [8]: from sympy import S

In [9]: S(setupstr)
Out[9]: LI(OAMHolo(OAMHolo(XX, e, 6), f, 2), a, f)


On Thu, 4 Apr 2019 at 15:41, Xuemei Gu <njux...@gmail.com> wrote:
>
> Thank you very much!
>
> I have another question:
>
> I get a string list such as  setupstr='LI(OAMHolo(OAMHolo(XX,e,6),f,2),a,f)'
>
> however in the string, LI OAMHolo are own defined functions, I don't know how 
> to replace them as functions.
> I want to know how to do in sympy like I use ToExpression in Mathematica.
>
> Thank you very much!
> best regards
> Mei
>
> On Mon, Apr 1, 2019 at 9:31 PM Aaron Meurer <asmeu...@gmail.com> wrote:
>>
>> I was hoping something like collect(x*y + x, [x, y], evaluate=False)
>> would do what you want, but it doesn't quite.
>>
>> You could create a Poly with the coefficients as variables and use
>> Poly.as_coefficients_dict.
>>
>> Aaron Meurer
>>
>> On Mon, Apr 1, 2019 at 1:02 PM Xuemei Gu <njux...@gmail.com> wrote:
>> >
>> >
>> > hey,
>> >
>> > I wander whether one has occurred such problem:
>> >
>> > I define a initial state:
>> >
>> > state=a[1]*b[0]*c[0]*d[0]*1j+a[1]*b[0]*c[0]*d[0] + a[2]*b[1]*c[1]*d[1]     
>> > # for some reason I have to do such decomposition
>> >
>> > datalist=state.as_coefficients_dict()
>> >
>> >
>> > I can get:
>> >             { FF2[0]*FF3[0]*FF4[0]: 1,  FF2[1]*FF3[1]*FF4[1]: 1,    
>> > I*FF2[0]*FF3[0]*FF4[0]: 1 }
>> >
>> > Now the problem is :
>> >
>> > Because I is a Imaginary number, it's not a symbol. How can I get 
>> > something such as  { FF2[0]*FF3[0]*FF4[0]: 1,  FF2[1]*FF3[1]*FF4[1]: 1,    
>> > FF2[0]*FF3[0]*FF4[0]: 1j} or { FF2[0]*FF3[0]*FF4[0]: 1+1j,  
>> > FF2[1]*FF3[1]*FF4[1]: 1 }
>> >
>> > Thank you very much!
>> >
>> >
>> >
>> >
>> > --
>> > 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 sympy+unsubscr...@googlegroups.com.
>> > To post to this group, send email to sympy@googlegroups.com.
>> > Visit this group at https://groups.google.com/group/sympy.
>> > To view this discussion on the web visit 
>> > https://groups.google.com/d/msgid/sympy/d4505824-6110-4541-8199-09b6768315d9%40googlegroups.com.
>> > For more options, visit https://groups.google.com/d/optout.
>>
>> --
>> You received this message because you are subscribed to a topic in the 
>> Google Groups "sympy" group.
>> To unsubscribe from this topic, visit 
>> https://groups.google.com/d/topic/sympy/GKRuQ1iYgEI/unsubscribe.
>> To unsubscribe from this group and all its topics, send an email to 
>> sympy+unsubscr...@googlegroups.com.
>> To post to this group, send email to sympy@googlegroups.com.
>> Visit this group at https://groups.google.com/group/sympy.
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/sympy/CAKgW%3D6J5MX4JqkoRkVaL1a6C57wpGBKaXBH%3DhOZeK-cPe04SKg%40mail.gmail.com.
>> For more options, visit https://groups.google.com/d/optout.
>
>
>
> --
> Xuemei Gu
> PhD Student
>
> State Key Laboratory for Novel Software Technology, Nanjing University
> 163 Xianlin Avenue, Qixia District, 210023, Nanjing City, China
>
> Institute for Quantum Optics and Quantum Information, Vienna
> Boltzmanngasse 3, A-1090 Vienna, Austria
>
> http://iqoqi-vienna.at/
> Office: +43 (0) 1 4277 29568
>
> --
> 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 sympy+unsubscr...@googlegroups.com.
> To post to this group, send email to sympy@googlegroups.com.
> Visit this group at https://groups.google.com/group/sympy.
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/sympy/CA%2BDAqr9yd3BkQnNYQ%3Dp6cXKccc8yZrFgirqxB3DmxEq%3Djy1grg%40mail.gmail.com.
> For more options, visit https://groups.google.com/d/optout.

-- 
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 sympy+unsubscr...@googlegroups.com.
To post to this group, send email to sympy@googlegroups.com.
Visit this group at https://groups.google.com/group/sympy.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/sympy/CAHVvXxR77kisBe8rkjsZ8cVgvqwf5Ggd5BuaKuBfFwRK0sWdsA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to