Interacting with Python scripts
A simple way to take Python code that already exists and bring it into a notebook is to use the %load
magic in a cell:
%load <filename>.p
Running this cell will load the contents of <filename>.py
into the current cell:
Running the cell again does not run the script – the point of using %load
was simply to include the script on the page, not execute it.
Using the %run
magic runs the script and inserts its output into the notebook as the output of that cell:
Tip
Using a notebook with tests
A notebook full of calls to test ...
Get Mastering IPython 4.0 now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.