The linecache Module
The linecache
module in Example 13-13 is used to read lines from module source code. It caches
recently visited modules (the entire source file, actually).
Example 13-13. Using the linecache module
File: linecache-example-1.py
import linecache
print linecache.getline("linecache-example-1.py", 5)
print linecache.getline("linecache-example-1.py", 5)
This module is used by the traceback
module.
Get Python Standard Library now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.