import sys %%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" %%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()) %%script python -Qnew print 1/3 %%script --bg --out bashout bash -c "while read line; do echo $line; sleep 1; done" line 1 line 2 line 3 line 4 line 5 import time tic = time.time() line = True while True: line = bashout.readline() if not line: break sys.stdout.write("%.1fs: %s" %(time.time()-tic, line)) sys.stdout.flush()