Modules are cached in Python

Опубликовано: 19 Февраль 2026
на канале: Python Morsels
469
24

When re-importing a module Python will use the cached version of your module (instead of reevaluating your code). To refresh a module while in the Python REPL, it's best to exit and start a new REPL.

Read an article version of this video at https://pym.dev/modules-are-cached/

Find more Python screencasts at https://pym.dev/screencasts/

00:00 Re-importing modules doesn't update them
00:34 Restarting the Python REPL to force-update our module
00:54 Python caches all imported modules
01:34 How to clear the cache for a module
02:16 Exit the REPL to refresh your cached Python modules