docstr: Re-run previous input
  
  By default, you can specify ranges of input history to be repeated
  (as with %history). With no arguments, it will repeat the last line.
  
  Options:
  
    -l <n> : Repeat the last n lines of input, not including the
    current command.
  
    -g foo : Repeat the most recent line which contains foo
docstr_tok: ["Re-run","previous","input","By","default",",","you","can","specify","ranges","of","input","history","to","be","repeated","(","as","with","%","history",")",".","With","no","arguments",",","it","will","repeat","the","last","line",".","Options",":","-l","<","n",">",":","Repeat","the","last","n","lines","of","input",",","not","including","the","current","command",".","-g","foo",":","Repeat","the","most","recent","line","which","contains","foo"]
code: def rerun(self, parameter_s=""):
      """Re-run previous input
  
      By default, you can specify ranges of input history to be repeated
      (as with %history). With no arguments, it will repeat the last line.
  
      Options:
  
        -l <n> : Repeat the last n lines of input, not including the
        current command.
  
        -g foo : Repeat the most recent line which contains foo
      """
      opts, args = self.parse_options(
          parameter_s, "l:g:", mode="string"
      )
      if "l" in opts:  # Last n lines
          try:
              n = int(opts["l"])
          except ValueError:
              print("Number of lines must be an integer")
              return
  
          if n == 0:
              print("Requested 0 last lines - nothing to run")
              return
          elif n < 0:
              print("Number of lines to rerun cannot be negative")
              return
  
          hist = self.shell.history_manager.get_tail(n)
      elif "g" in opts:  # Search
          p = "*" + opts["g"] + "*"
          hist = list(self.shell.history_manager.search(p))
          for l in reversed(hist):
              if "rerun" not in l[2]:
                  hist = [l]  # The last match which isn't a %rerun
                  break
          else:
              hist = []  # No matches except %rerun
      elif args:  # Specify history ranges
          hist = self.shell.history_manager.get_range_by_str(args)
      else:  # Last line
          hist = self.shell.history_manager.get_tail(1)
      hist = [x[2] for x in hist]
      if not hist:
          print("No lines in history match specification")
          return
      histlines = "\n".join(hist)
      print("=== Executing: ===")
      print(histlines)
      print("=== Output: ===")
      self.shell.run_cell("\n".join(hist), store_history=False)
  
file_path: catboost/contrib/python/ipython/py3/IPython/core/magics/history.py
imports: import os
  import sys
  from io import open
  import fnmatch
  from IPython.core.error import StdinNotImplementedError
  from IPython.core.magic import Magics, magics_class, line_magic
  from IPython.core.magic_arguments import argument, magic_arguments, parse_argstring
  from IPython.testing.skipdoctest import skip_doctest
  from IPython.utils import io
label_desc: Use image node_id 3 for calling the HistoryMagics obj's underlying member method code with example usage: obj.rerun(parameter_s) without return types