How to: Auto-import common modules in ipython shell

April 9, 2012

if you use ipython, save yourself some typing by importing common modules automatically on load.

edit your ipythonrc file (mine lives in ~/.ipython/) as such:
import_mod math os os.path sys random itertools re json hashlib time urllib urllib2 urlparse
import_some datetime datetime date timedelta
import_mod x y z is like: import x, y, z
import_some x y z is like: from x import y, z
Python 2.6.5 (r265:79063, Apr 16 2010, 13:09:56)
IPython 0.10 — An enhanced Interactive Python.
In [1]:
Out[1]: datetime.datetime(2012, 4, 9, 12, 18, 44, 570264)
look ma, no imports!
Written by

Read more from

The World's Most Powerful Mobile Data Collection Platform

Start a FREE 30-day CommCare trial today. No credit card required.

Get Started

Learn More

Get the latest news delivered
straight to your inbox