IPython Intro Breakout Session

Interactive exploration

I have shown you the Zen of Python. But if you search through all of the python source code, you will not find the word "Zen" anywhere.

Use <TAB>, ? and ?? on the this module to decode this string:

In [ ]:
import this

secret = "Tbbq Wbo! abj tb fvta hc sbe gur znvyvat yvfg bire ng vclguba.bet"

Timing information

Josh mentioned that there are two range commands, range and xrange.

Run the code below to see which one is faster, and then read the documentation for the two to see why this is the case.

In [ ]:
timeit?
In [ ]:
%timeit range(100)
In [ ]:
%timeit xrange(100)

Configuration file options

Create the stub default profile (if you haven't already)

$ ipython profile create



This will create the stubs for the default profile

now you can change these defaults.

To find where your profile is stored:

In [1]: import IPython

In [2]: IPython.utils.path.locate_profile()



Example:if you want the _ and __ methods to show up by default when doing tab-completion

c.IPCompleter.omit__names

Another example: you can add your own startup message (or execute your desired commands at startup) like I have:

.../profile_default/startup/README
In [2]:
import IPython
IPython.utils.path.locate_profile()
Out[2]:
u'/home/pi/.ipython/profile_default'
In [3]:
IPython.utils.path.locate_profile()+'/startup/README'
Out[3]:
u'/home/pi/.ipython/profile_default/startup/README'
In [ ]:
cat IPython.utils.path.locate_profile()+'/startup/README'