How do I reload a python submodule?
Question: I'm loading a submodule in python (2.7.10) with `from app import sub` where
`sub` has a `config` variable. So I can run `print sub.config` and see a bunch
of config variables. Not super complex.

If I change the config variables in the script, there must be a way to reload
the module and see the change. I found a few instructions that indicated that
`reload(app.sub)` would work, but I get an error:

    
    
    NameError: name 'app' is not defined
    

And if I do just `reload(sub)` the error is:

    
    
    TypeError: reload() argument must be module
    

If I do `import app` I can view the config with `print app.sub.config` and
reload with `reload(app)`

\-- if I do `import app` and then run

I found instructions to automate reloading: [Reloading submodules in
IPython](http://stackoverflow.com/questions/5364050/reloading-submodules-in-
ipython)

but is there no way to reload a submodule manually?


Answer: When you `from foo import bar`, you now have a module object named `bar` in
your namespace, so you can

    
    
    from foo import bar
    
    bar.do_the_thing()  # or whatever
    
    reload(bar)
    

If you want some more details on how different import forms work, I personally
found [this answer](http://stackoverflow.com/a/2725668/939586) particularly
helpful, myself.

