MCPcopy Index your code
hub / github.com/ipython/ipython / get_tail

Method get_tail

IPython/core/history.py:443–475  ·  view source on GitHub ↗

Get the last n lines from the history database. 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 late

(
        self,
        n: int = 10,
        raw: bool = True,
        output: bool = False,
        include_latest: bool = False,
    )

Source from the content-addressed store, hash-verified

441
442 @catch_corrupt_db
443 def get_tail(
444 self,
445 n: int = 10,
446 raw: bool = True,
447 output: bool = False,
448 include_latest: bool = False,
449 ) -> Iterable[tuple[int, int, InOrInOut]]:
450 """Get the last n lines from the history database.
451
452 Parameters
453 ----------
454 n : int
455 The number of lines to get
456 raw, output : bool
457 See :meth:`get_range`
458 include_latest : bool
459 If False (default), n+1 lines are fetched, and the latest one
460 is discarded. This is intended to be used where the function
461 is called by a user command, which it should not return.
462
463 Returns
464 -------
465 Tuples as :meth:`get_range`
466 """
467 self.writeout_cache()
468 if not include_latest:
469 n += 1
470 cur = self._run_sql(
471 "ORDER BY session DESC, line DESC LIMIT ?", (n,), raw=raw, output=output
472 )
473 if not include_latest:
474 return reversed(list(cur)[1:])
475 return reversed(list(cur))
476
477 @catch_corrupt_db
478 def search(

Callers 2

get_last_session_idMethod · 0.95

Calls 2

writeout_cacheMethod · 0.95
_run_sqlMethod · 0.95

Tested by 1