Skip to content

Instantly share code, notes, and snippets.

@scottrogowski
Created March 26, 2015 15:54
Show Gist options
  • Save scottrogowski/16c4c146fb9b19c1a417 to your computer and use it in GitHub Desktop.
Save scottrogowski/16c4c146fb9b19c1a417 to your computer and use it in GitHub Desktop.
Open a IPython REPL using the arguments as libraries to be imported
#!/usr/bin/env python
# Open a IPython REPL using the arguments as libraries to be imported via `import *`.
# Also imports a few stdlib libraries
# For example:
# $ i lib/lib_to_be_imported.py
# does
# from lib.lib_to_be_imported import *
# before the REPL starts
import sys
import os
import re
from IPython import embed
if __name__ == "__main__":
args = list(sys.argv)[1:]
args = [a.replace('/', '.') for a in args]
args = [re.sub('\.py$', '', a) for a in args]
sys.path = [''] + sys.path
for arg in args:
exec "from %s import *" % arg
from subprocess import *
from datetime import *
from collections import *
import logging
import json
import urlparse
import urllib
import urllib2
from pprint import pprint as pp
embed()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment