Skip to content

Instantly share code, notes, and snippets.

@fberger
Created April 2, 2014 03:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save fberger/9927732 to your computer and use it in GitHub Desktop.
Save fberger/9927732 to your computer and use it in GitHub Desktop.
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