docstr: Repeat a command, or get command to input line for editing.
  
  %recall and %rep are equivalent.
  
  - %recall (no arguments):
  
  Place a string version of last computation result (stored in the
  special '_' variable) to the next input prompt. Allows you to create
  elaborate command lines without using copy-paste::
  
       In[1]: l = ["hei", "vaan"]
       In[2]: "".join(l)
      Out[2]: heivaan
       In[3]: %recall
       In[4]: heivaan_ <== cursor blinking
  
  %recall 45
  
  Place history line 45 on the next input prompt. Use %hist to find
  out the number.
  
  %recall 1-4
  
  Combine the specified lines into one cell, and place it on the next
  input prompt. See %history for the slice syntax.
  
  %recall foo+bar
  
  If foo+bar can be evaluated in the user namespace, the result is
  placed at the next input prompt. Otherwise, the history is searched
  for lines which contain that substring, and the most recent one is
  placed at the next input prompt.
docstr_tok: ["Repeat","a","command",",","or","get","command","to","input","line","for","editing",".","%","recall","and","%","rep","are","equivalent",".","-","%","recall","(","no","arguments",")",":","Place","a","string","version","of","last","computation","result","(","stored","in","the","special","'","_","'","variable",")","to","the","next","input","prompt",".","Allows","you","to","create","elaborate","command","lines","without","using","copy-paste",":",":","In","[","1","]",":","l","=","[","``","hei","''",",","``","vaan","''","]","In","[","2","]",":","``","''",".join","(","l",")","Out","[","2","]",":","heivaan","In","[","3","]",":","%","recall","In","[","4","]",":","heivaan_","<","==","cursor","blinking","%","recall","45","Place","history","line","45","on","the","next","input","prompt",".","Use","%","hist","to","find","out","the","number",".","%","recall","1-4","Combine","the","specified","lines","into","one","cell",",","and","place","it","on","the","next","input","prompt",".","See","%","history","for","the","slice","syntax",".","%","recall","foo+bar","If","foo+bar","can","be","evaluated","in","the","user","namespace",",","the","result","is","placed","at","the","next","input","prompt",".","Otherwise",",","the","history","is","searched","for","lines","which","contain","that","substring",",","and","the","most","recent","one","is","placed","at","the","next","input","prompt","."]
code: def recall(self, arg):
      r"""Repeat a command, or get command to input line for editing.
  
      %recall and %rep are equivalent.
  
      - %recall (no arguments):
  
      Place a string version of last computation result (stored in the
      special '_' variable) to the next input prompt. Allows you to create
      elaborate command lines without using copy-paste::
  
           In[1]: l = ["hei", "vaan"]
           In[2]: "".join(l)
          Out[2]: heivaan
           In[3]: %recall
           In[4]: heivaan_ <== cursor blinking
  
      %recall 45
  
      Place history line 45 on the next input prompt. Use %hist to find
      out the number.
  
      %recall 1-4
  
      Combine the specified lines into one cell, and place it on the next
      input prompt. See %history for the slice syntax.
  
      %recall foo+bar
  
      If foo+bar can be evaluated in the user namespace, the result is
      placed at the next input prompt. Otherwise, the history is searched
      for lines which contain that substring, and the most recent one is
      placed at the next input prompt.
      """
      if not arg:  # Last output
          self.shell.set_next_input(str(self.shell.user_ns["_"]))
          return
          # Get history range
      histlines = self.shell.history_manager.get_range_by_str(arg)
      cmd = "\n".join(x[2] for x in histlines)
      if cmd:
          self.shell.set_next_input(cmd.rstrip())
          return
  
      try:  # Variable in user namespace
          cmd = str(eval(arg, self.shell.user_ns))
      except Exception:  # Search for term in history
          histlines = self.shell.history_manager.search("*" + arg + "*")
          for h in reversed([x[2] for x in histlines]):
              if "recall" in h or "rep" in h:
                  continue
              self.shell.set_next_input(h.rstrip())
              return
      else:
          self.shell.set_next_input(cmd.rstrip())
          return
      print("Couldn't evaluate or find in history:", arg)
  
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 2 for calling the HistoryMagics obj's underlying member method code with example usage: obj.recall(arg) without return types