all Python 3linecachefunction
linecache.checkcache()
cache
Checks whether cached files have changed on disk and drops the stale entries from the linecache cache.
Syntax
linecache.checkcache(filename=None)
A change is detected by size and modification time, not by content: an edit of the same size within the same second may go unnoticed. Without an argument every cached file is checked, which costs more than checkcache(filename) for one file. The entry of a deleted file is dropped too, and getline returns ''.
Examples
import linecache
with open('data.py', 'w') as f:
f.write('y = 2\n')
print(repr(linecache.getline('data.py', 1))) # → 'y = 2\n'
with open('data.py', 'w') as f:
f.write('y = 20 # changed\n')
print(repr(linecache.getline('data.py', 1))) # → 'y = 2\n' — из кэша
linecache.checkcache('data.py')
print(repr(linecache.getline('data.py', 1))) # → 'y = 20 # changed\n'
See also
Open in the full glossarydocs.python.orgReport an inaccuracy