iPython notebook: store interactive output preview

657 views Asked by At

I really like the interactive functionality of the new iPython notebook.

I often use it to replace plots, and make them more informative.

The problem is, that the output of these interactive cells is not stored in the notebook (for offline viewing).

When I shutdown and reopen the notebook, there is no preview for these cells (while there is for non-interactive cells). The same happens when previewing on github.

Is there a way to dó store the (static) output of interactive cells? I understand that the interactive cell will have to be run in order to be interactive, but I would like to store a snapshot of the cell. The exact parameters that are being used to execute the function do not matter too much for me (though it would be nice to be able to set them).

Example: running an interactive notebook: notebook-running

Example: after closing and reopening: notebook-reopened

I am using:

  • python 3.6.1
  • iPython 4.6.1
1

There are 1 answers

4
misakawa On

Renew : Sorry for my bad comprehension, and what you want must be the following codes: Represent decoretor

def represent(**default_args):
    def _wrapper_func(func):
        print("See some examples here!")
        print(f"[Example] Default arguments :{default_args}")
        print(f">> {func.__name__}(**{default_args})")
        print(f">> {func(**default_args)}")
        def _setargs(*args, **kwargs):
            return func(*args, **kwargs)
        return _setargs
    return _wrapper_func

------------------------------The old answer-------------------------------

It seems that you just need some snapshot to show how you dealt with the codes before. The solution is easy, see the following picture I give out. Guide

Save it in some specific place and review it if you need, while you have forget the meanings of you once codes!