How to reload a module’s function in Python?

As of today, the proper way of doing this is:

import sys, importlib
importlib.reload(sys.modules['foo'])
from foo import bar

Tested on python 2.7, 3.5, 3.6.

Leave a Comment