Showing assignment results in IPython notebook?

折月煮酒 提交于 2019-12-07 16:47:25

This feature is not part of the core functionality of IPython. It has instead been incorporated into the extension displaytools. Quote from the repo:

Load this extension with %load_ext displaytools or %reload_ext displaytools. The latter is useful for debugging.

Example invocation:

my_random_variable = np.random.rand() ##

Due to the special comment ## the extension inserts the line display(my_random_variable) to the source code, before it is passed to the interpreter, i.e. before its execution.

That way, additional output is generated, which makes the notebook be more comprehensible (because the reader knows the content of my_random_variable). It saves the typing effort and the code duplication of manually adding display(my_random_variable).

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!