[IPython-dev] Execution semantics and how to set them

Matthias BUSSONNIER bussonniermatthias at gmail.com
Sun Jan 25 14:06:39 EST 2015


Le 25 janv. 2015 à 19:57, Thomas Kluyver a écrit :
> First, let me emphasise that all of this is only relevant for executing Python code. If you're building a kernel for another language, you should ignore all of this. That documentation page is only about IPython's own kernel.
> 
> The three modes described on that page (exec, eval, single) are compilation modes of Python itself, passed as arguments to the built-in compile() function.
> 
> The parameter passed to our run_ast_nodes() method (which can be all, none, last or last_expr) controls which of a list of AST nodes are compiled in 'single' mode. Our default of last_expr is chosen specifically so that the for loop example above does not produce output, because we think that's more likely to be annoying than useful. There is no way to control this from the frontend, and I don't think we have any intention to add such a feature.
> 
> For your own kernel, you should implement whatever display of output makes sense given the language and the likely users. For Python, we decided that it makes sense to automatically display the result of the last statement if that statement is an expression, and implemented that using the details described above. For R, I implemented similar behaviour based on the evaluate package by creating an output_handler with a value= parameter.
> 
> Which language are you working on a kernel for?

Shot in the dark, helped by google IPerl: 

https://github.com/zmughal/p5-Devel-IPerl

-- 
M

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/ipython-dev/attachments/20150125/c844670a/attachment.html>


More information about the IPython-dev mailing list