Join GitHub today
Add new interactivity mode for ast. #10598
yeah, of course it's not the default :-)
Hum inject something at the end like that:
At the same time when the expression of a of a cell display something there is always an
If we're injecting
Maybe there's a nicer way to do this - instead of modifying the AST, inspect it to find the target of the final assignment, and then record some information which says 'if this code completes successfully, print the value of
Well that's almost exactly what the above do. it calls display on the last assignment target.
Here is my argument against having it displayed and not triggerd as part of display hook.
One the the two below methods are doing
def load_something(): display(...)
def load_somethingelse(): return ...
$ ipython Python 3.6.0 |Continuum Analytics, Inc.| (default, Dec 23 2016, 13:19:00) Type 'copyright', 'credits' or 'license' for more information IPython 6.1.0.dev -- An enhanced Interactive Python. Type '?' for help. In : %config TerminalInteractiveShell.ast_node_interactivity='display_last_expr_or_assign' In : from dummymod import load_cars, load_iris In : a = load_iris() ================= Id | types ================= 1 | A 2 | B 3 | A None In : b = load_cars() ================= Id | types ================= I | E II | F III | G
With the current implementation that would be disambiguated by having (or not) an Out:
In : a = load_iris() ================= Id | types ================= 1 | A 2 | B 3 | A In : b = load_cars() Out: ================= Id | types ================= I | E II | F III | G
Well now both are implemented so I can push 2 options.