-
-
Save scottrogowski/16c4c146fb9b19c1a417 to your computer and use it in GitHub Desktop.
Open a IPython REPL using the arguments as libraries to be imported
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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