File: class/Workbook/Examples/Lecture6/fixer.py

editor = 'vi'  # your editor's name

def python(cmd):
    import __main__
    namespace = __main__.__dict__
    exec cmd in namespace, namespace

def edit(filename):
    import os
    os.system(editor + ' ' + filename)

def fix(modname):
    import sys                      # edit,(re)load
    edit(modname + '.py')
    if modname in sys.modules.keys():
        python('reload(' + modname + ')')
    else:
        python('import ' + modname)



[Home page] Books Code Blog Python Author Train Find ©M.Lutz