%lsmagic %matplotlib inline import numpy as np import matplotlib.pyplot as plt %timeit np.linalg.eigvals(np.random.rand(100,100)) %%timeit a = np.random.rand(100, 100) np.linalg.eigvals(a) %%capture capt from __future__ import print_function import sys print('Hello stdout') print('and stderr', file=sys.stderr) capt.stdout, capt.stderr capt.show() %%writefile foo.py print('Hello world') %run foo %%script python import sys print 'hello from Python %s' % sys.version %%script python3 import sys print('hello from Python: %s' % sys.version) %%ruby puts "Hello from Ruby #{RUBY_VERSION}" %%bash echo "hello from $BASH" %%script ./lnum.py my first line my second more %%bash echo "hi, stdout" echo "hello, stderr" >&2 %%bash --out output --err error echo "hi, stdout" echo "hello, stderr" >&2 print(error) print(output) %%ruby --bg --out ruby_lines for n in 1...10 sleep 1 puts "line #{n}" STDOUT.flush end ruby_lines print(ruby_lines.read())