docs: def var_expand(self, cmd, depth=0, formatter=DollarFormatter()):
          """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.
          """
          ns = self.user_ns.copy()
          try:
              frame = sys._getframe(depth + 1)
          except ValueError:
              # This is thrown if there aren't that many frames on the stack,
              # e.g. if a script called run_line_magic() directly.
              pass
          else:
              ns.update(frame.f_locals)
  
          try:
              # We have to use .vformat() here, because 'self' is a valid and common
              # name, and expanding **ns for .format() would make it collide with
              # the 'self' argument of the method.
              cmd = formatter.vformat(cmd, args=[], kwargs=ns)
          except Exception:
              # if formatter couldn't format, just let it go untransformed
              pass
          return cmd