The displayhook just does print repr(x) and print a little bit nicer in 
Sage. It would be better to call the displayhook than printing directly, 
but thats not the issue here.

When I said that you need to walk the ast then of course you have to first 
preparse, then compile the ast.



On Sunday, November 3, 2013 7:43:35 PM UTC, William wrote:
>
> On Sun, Nov 3, 2013 at 11:39 AM, Volker Braun 
> <vbrau...@gmail.com<javascript:>> 
> wrote: 
> > Manually parsing python code is spectacularly ugly and, as we saw, error 
> > prone. The right way to do it is to use Python's own parser and then 
> either 
> > take apart the ast or use a NodeTransformer to insert the desired print 
> > statements at the ends of if-bodies. 
>
> Unfortunately, the input isn't Python code, it's sage worksheet code, 
> because of both the preparser and the % cell and line decorators. 
>
> Fortunately, I think there's no insertion of actual print statements. 
> Python has something called sys.displayhook, which gets called 
> automatically when exec'ing. 
>
>

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

Reply via email to