Pretty print expressions

閲覧: 24 回
最初の未読メッセージにスキップ

Luv Agarwal

未読、
2016/04/07 7:32:462016/04/07
To: sympy
Hey, I am doing some calculations. I wanted to print the following string as pretty_print:

s = 'L*P**2*Q**3{-b*l*conjugate(p)|00\ + -a*p*q**3|11\}'

One way I could think is to apply parse_expr first and then pretty print but it can't take '\'s and brackets (Is there any way to ignore these characters or take them as symbols?). Other way I tried is to parse the string in parts (so that I can ignore the unparsable characters by not parsing them and print them later separately) and then pretty_print them with spaces between them. But I couldn't find any way to pretty print multiple expressions or strings with spaces between them. I tried doing pretty_print(L*P**2*Q**3), pretty_print('{'). But it's still printing newlines between them.

How should I do it?

Luv Agarwal

未読、
2016/04/07 8:50:312016/04/07
To: sympy
Also, is this the right place to ask questions?

Oscar Benjamin

未読、
2016/04/07 9:30:442016/04/07
To: sympy
On 7 April 2016 at 13:50, Luv Agarwal <luvaga...@gmail.com> wrote:
> Also, is this the right place to ask questions?

It is although I don't know the answer to your question. Be patient...

Aaron Meurer

未読、
2016/04/07 14:07:572016/04/07
To: sy...@googlegroups.com
Is \00\ supposed to be a symbol named "\00\"? If so, you can wrap it
with Symbol and a string like Symbol(r"\00\"). That is

s = 'L*P**2*Q**3{-b*l*conjugate(p)*Symbol(r"\00\") + -a*p*q**3*Symbol("\11\")}'

Aaron Meurer
> --
> 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+un...@googlegroups.com.
> To post to this group, send email to sy...@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/7e24e95b-5b81-4451-b1d8-0798cf2dab5c%40googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
全員に返信
投稿者に返信
転送
新着メール 0 件