Created
April 2, 2014 03:59
-
-
Save fberger/9927732 to your computer and use it in GitHub Desktop.
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
from IPython.core import ipapi | |
def istore(): | |
'''Extracts all variable names used in assignments from the input history | |
and stores them.''' | |
ipy = ipapi.get() | |
for v in assignees(assignments(ipy.history_manager.input_hist_raw)): | |
try: | |
ipy.magic('store %s' % v) | |
except: | |
pass | |
def assignments(hist): | |
return (h for h in hist if '=' in h) | |
def assignees(assignments): | |
return (a.split('=')[0].strip() for a in assignments) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment