Forum Archive

Pythonista reload all modules?

JadedTuna

Is there a way to reload all the modules, or at least some folder in Pythonista? It is really annoying to restart it, or to use reload() functions everywhere.
Is there some other way?

SpotlightKid

You might try this somewhat hackish function:

import sys

def reload_all():
    for name, module in sorted(sys.modules.iteritems()):
        if hasattr(module, '__file__') and '.' not in name:
            print "Reloading module '%s'..." % name
            reload(module)
dgelessus

Here's an improved version that reloads all modules located in ~/Documents and subfolders, including site-packages:

http://github.com/dgelessus/pythonista-scripts/blob/master/reload_all.py