# Tab completion l = [] l.append(2) # Better help system. obj? l? # Read the source code of function def square(no): """Square a given number""" return no * no square? # same as help(square) square?? # Let's display all inbuiltin function in python, starting with s. # How can we do it ? # Regex !!! s*? # Ipython stores all the input and Output in dictionaries. # Lets see what was the input for cell 4. In[4] Out[4] # Expect KeyError, since Input didn't produce an output. a = 23; a+23 In[12] Out[12] # _ -> Previous cell output # __ -> previous to previous cell output print _, __ # *nix has history command, in similar way IPython also has a way to display inputs %history -n 1-5 # From IPython it is possible to run linux command # For command with arguments syntax is `%ls -la` !ls pwd # IPython also allows to store output of a command files = !ls / print(files) !echo $files # In Python any method starting with __ is called magic method. Similarly in IPython %%command is magic function. %timeit [] + [] # only one line is possible %%timeit x = range(100000) #multiline is possible x.append(23) %%bash echo "My shell is:" $SHELL %%ruby puts "Guido and Matz use Emacs." %lsmagic %%writefile hello.py # -*- coding: utf-8 -*- def greet(name): return "Hello {}".format(name) if __name__ == "__main__": print(greet("Pythonistas!")) !cat hello.py %run hello.py !python hello.py # We all know cell can take Markdown or code snippet. The output is displayed in browser. So IPython notebook can display Images # videos, embed, plot graphs etc ... # Lets show off from IPython.display import Image, YouTubeVideo YouTubeVideo("d1a4Jbjc-vU") Image("/Users/kracekumar/code/imgee/imgee/static/uploads/1b562ef1a0174658ad67dbf19ee5c45e_w75_h76.jpeg") Image("http://imgs.xkcd.com/comics/python.png") from IPython.display import HTML s = """
Name Twitter
Kracekumar @kracetheking
James Dennis @j2labs
""" HTML(s) # How about embeding IFrame ? Soundcloud ? HTML("""""") # Future ? # Lot more features