class_docstr: A class to organize all history-related functionality in one place.
      
class_docstr_tok: ["A","class","to","organize","all","history-related","functionality","in","one","place","."]
docstr: Get the last n lines from the history database.
  
  Most recent entry last.
  
  Completion will be reordered so that that the last ones are when
  possible from current session.
  
  Parameters
  ----------
  n : int
      The number of lines to get
  raw, output : bool
      See :meth:`get_range`
  include_latest : bool
      If False (default), n+1 lines are fetched, and the latest one
      is discarded. This is intended to be used where the function
      is called by a user command, which it should not return.
  
  Returns
  -------
  Tuples as :meth:`get_range`
docstr_tok: ["Get","the","last","n","lines","from","the","history","database",".","Most","recent","entry","last",".","Completion","will","be","reordered","so","that","that","the","last","ones","are","when","possible","from","current","session",".","Parameters","--","--","--","--","--","n",":","int","The","number","of","lines","to","get","raw",",","output",":","bool","See",":","meth",":","`","get_range","`","include_latest",":","bool","If","False","(","default",")",",","n+1","lines","are","fetched",",","and","the","latest","one","is","discarded",".","This","is","intended","to","be","used","where","the","function","is","called","by","a","user","command",",","which","it","should","not","return",".","Returns","--","--","--","-","Tuples","as",":","meth",":","`","get_range","`"]
code: def get_tail(
      self, n=10, raw=True, output=False, include_latest=False
  ):
      """Get the last n lines from the history database.
  
      Most recent entry last.
  
      Completion will be reordered so that that the last ones are when
      possible from current session.
  
      Parameters
      ----------
      n : int
          The number of lines to get
      raw, output : bool
          See :meth:`get_range`
      include_latest : bool
          If False (default), n+1 lines are fetched, and the latest one
          is discarded. This is intended to be used where the function
          is called by a user command, which it should not return.
  
      Returns
      -------
      Tuples as :meth:`get_range`
      """
      self.writeout_cache()
      if not include_latest:
          n += 1
      # cursor/line/entry
      this_cur = list(
          self._run_sql(
              "WHERE session == ? ORDER BY line DESC LIMIT ?  ",
              (self.session_number, n),
              raw=raw,
              output=output,
          )
      )
      other_cur = list(
          self._run_sql(
              "WHERE session != ? ORDER BY session DESC, line DESC LIMIT ?",
              (self.session_number, n),
              raw=raw,
              output=output,
          )
      )
  
      everything = this_cur + other_cur
  
      everything = everything[:n]
  
      if not include_latest:
          return list(everything)[:0:-1]
      return list(everything)[::-1]
  
imports: import atexit
  import datetime
  from pathlib import Path
  import re
  import sqlite3
  import threading
  from traitlets.config.configurable import LoggingConfigurable
  from decorator import decorator
  from IPython.utils.decorators import undoc
  from IPython.paths import locate_profile
  from traitlets import Any, Bool, Dict, Instance, Integer, List, Unicode, Union, TraitError, default, observe
label_desc: Use image node_id 9 for calling the HistoryManager obj's underlying member method code with example usage: obj.get_tail(n, raw, output, include_latest) and returns: list, list