def var_expand(self, cmd, depth=0, formatter=DollarFormatter()):
    "Expand python variables in a string.\n\n        The depth argument indicates how many frames above the caller should\n        be walked to look for the local namespace where to expand variables.\n\n        The global namespace for expansion is always the user's interactive\n        namespace.\n        "
    ns = self.user_ns.copy()
    try:
        frame = sys._getframe((depth + 1))
    except ValueError:
        pass
    else:
        ns.update(frame.f_locals)
    try:
        cmd = formatter.vformat(cmd, args=[], kwargs=ns)
    except Exception:
        pass
    return cmd
Expand python variables in a string.

The depth argument indicates how many frames above the caller should
be walked to look for the local namespace where to expand variables.

The global namespace for expansion is always the user's interactive
namespace.
def var_expand(self, cmd, depth=0, formatter=DollarFormatter()):
    "Expand python variables in a string.\n\n        The depth argument indicates how many frames above the caller should\n        be walked to look for the local namespace where to expand variables.\n\n        The global namespace for expansion is always the user's interactive\n        namespace.\n        "
    ns = self.user_ns.copy()
    try:
        frame = sys._getframe((depth + 1))
    except ValueError:
        pass
    else:
        ns.update(frame.f_locals)
    try:
        cmd = formatter.vformat(cmd, args=[], kwargs=ns)
    except Exception:
        pass
    return cmd