Python Glossary Русский

all Python 3linecachefunction

linecache.clearcache()

cache

Empties the linecache cache completely: the next getline re-reads files from disk.

Syntax

linecache.clearcache()

It clears the cache of the whole process, including lines traceback uses to show tracebacks. To refresh one changed file, checkcache(filename) is more precise: it drops only stale entries. clearcache is useful in long-running processes that have read many files and keep their text in memory.

Examples

import linecache
with open('data.py', 'w') as f:
    f.write('x = 1\n')
linecache.getline('data.py', 1)
print('data.py' in linecache.cache)  # → True
linecache.clearcache()
print('data.py' in linecache.cache)  # → False

See also

Open in the full glossarydocs.python.orgReport an inaccuracy