def extract_vars_above(*names):

    callerNS = sys._getframe(2).f_locals
    return dict((k,callerNS[k]) for k in names)
Extract a set of variables by name from another frame.
dataset/ETHPy150Open ipython/ipython-py3k/IPython/utils/frame.py/extract_vars_above