MCPcopy Create free account
hub / github.com/ipython/ipython / get_tail

Method get_tail

IPython/core/history.py:344–369  ·  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 latest one

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

Source from the content-addressed store, hash-verified

342
343 @catch_corrupt_db
344 def get_tail(self, n=10, raw=True, output=False, include_latest=False):
345 """Get the last n lines from the history database.
346
347 Parameters
348 ----------
349 n : int
350 The number of lines to get
351 raw, output : bool
352 See :meth:`get_range`
353 include_latest : bool
354 If False (default), n+1 lines are fetched, and the latest one
355 is discarded. This is intended to be used where the function
356 is called by a user command, which it should not return.
357
358 Returns
359 -------
360 Tuples as :meth:`get_range`
361 """
362 self.writeout_cache()
363 if not include_latest:
364 n += 1
365 cur = self._run_sql("ORDER BY session DESC, line DESC LIMIT ?",
366 (n,), raw=raw, output=output)
367 if not include_latest:
368 return reversed(list(cur)[1:])
369 return reversed(list(cur))
370
371 @catch_corrupt_db
372 def search(self, pattern="*", raw=True, search_raw=True,

Callers 5

get_last_session_idMethod · 0.95
test_historyFunction · 0.45
historyMethod · 0.45
rerunMethod · 0.45

Calls 2

writeout_cacheMethod · 0.95
_run_sqlMethod · 0.95

Tested by 1

test_historyFunction · 0.36