On this page
linecache.getline
Prev: linecache.clearcache | Up: linecache | Next: linecache.lazycache
Rel: linecache.checkcache, linecache.clearcache, linecache.lazycache
Ref: docs.python.org — linecache.getline
Tags: #public #python3 #stdlib #linecache
Import
import linecache
from linecache import getline
Signature & Overview
linecache.getline(filename, lineno, module_globals=None)
Get a line for a Python source file from the cache.
Usage
import linecache
line = linecache.getline(linecache.__file__, 1)
assert isinstance(line, str) and len(line) > 0
Gotchas
- 1-based line numbers and never raises: Missing files or out-of-range lines return
"".
REPL Inspect
from linecache import getline
help(getline)
Linked from
Related notes
- tuts/python3/stdlib_module/linecache/checkcache Linked here; links to this page; shared tags: #linecache, #stdlib
- tuts/python3/stdlib_module/linecache/clearcache Linked here; links to this page; shared tags: #linecache, #stdlib
- tuts/python3/stdlib_module/linecache/lazycache Linked here; links to this page; shared tags: #linecache, #stdlib
- tuts/python3/stdlib_module/linecache Linked here; links to this page; shared tags: #stdlib
- tuts/c/stdlib shared tags: #stdlib
- tuts/c/stdlib/assert shared tags: #stdlib
- tuts/c/stdlib/assert/assert shared tags: #stdlib
- tuts/c/stdlib/assert/static_assert shared tags: #stdlib
- tuts/c/stdlib/ctype shared tags: #stdlib
- tuts/c/stdlib/ctype/isalpha shared tags: #stdlib