__pycache__ is not your enemy, but it will lie to youYou delete a module. The import still works. You rename a class. Old bytecode still runs. You spend an hour asking “why is this line still executing?”
👉 Python caches compiled bytecode in
__pycache__. That’s great for speed. But when you delete a .py file, the .pyc stays forever. Python finds it and imports it like nothing happened. No warning. No error.✅ The idea: clear
__pycache__ before you debug import issues. Or set PYTHONDONTWRITEBYTECODE=1 in development. Or just accept that Python will gaslight you once a month and move on.