Excellent!  This is exactly what I was looking for.

Does S() return the tree in memory?

On Wednesday, April 6, 2016 at 4:32:32 PM UTC-5, Nathan Goldbaum wrote:
>
>
>
> On Wed, Apr 6, 2016 at 4:09 PM, Nathan Hayden <[email protected] 
> <javascript:>> wrote:
>
>> Hi, I'm new to SymPy, but I'm using it to do some simple things already.
>>
>> I'm wondering, can I feed SymPy an expression and get a tree 
>> representation back showing me the order of operations used to evaluate the 
>> expression?  I know this is all handled under the hood, but I don't know if 
>> it's exposed.
>>
>>
>> For example, for the expression:   4 * 5 + 6 * (1 + 2)
>>
>> I'd like to get something like:
>>
>>                        +
>>                     /      \
>>                   *         *
>>                /    \     /    \
>>              4     5   6      +
>>                                 /  \
>>                               1    2
>>
>> Is this a thing?
>>
>
> from sympy.printing.tree import print_tree
> from sympy import S
>
> print_tree(S(' 4 * 5 + 6 * (1 + 2)', evaluate=False))
>
> I'm not sure there's a way to make it print like you want, but you should 
> be able to whip something up following this:
>
> http://docs.sympy.org/latest/tutorial/manipulation.html
>
> (particularly the bits toward the bottom).
>
> -Nathan
>  
>
>> -- 
>> 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] <javascript:>.
>> To post to this group, send email to [email protected] <javascript:>
>> .
>> 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/90597353-0ff0-42c8-a554-59f4b069cba2%40googlegroups.com
>>  
>> <https://groups.google.com/d/msgid/sympy/90597353-0ff0-42c8-a554-59f4b069cba2%40googlegroups.com?utm_medium=email&utm_source=footer>
>> .
>> 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 [email protected].
To post to this group, send email to [email protected].
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/96bc2f21-03a4-4cf7-8567-93bc43446c08%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to