in pythonwhen you type import some_libthe code in some_lib is executed and all the variablesfunctionsand imports defined within are stored in the newly created some_lib module namespace the next time you type import some_libyou will get reference to the existing module namespace the potential difficulty in interactive code development in ipython comes when yousay%run script that depends on some other module where you may have made changes suppose had the following code in test_script pyimport some_lib [ result some_lib get_answer(xyif you were to execute %run test_script py then modify some_lib pythe next time you execute %run test_script py you will still get the old version of some_lib because of python' "load-oncemodule system this behavior differs from some other data analysis environmentslike matlabwhich automatically propagate code changes to cope with thisyou have couple of options the first way is to use python' built-in reload functionaltering test_script py to look like the followingimport some_lib reload(some_libx [ result some_lib get_answer(xythis guarantees that you will get fresh copy of some_lib every time you run test_script py obviouslyif the dependencies go deeperit might be bit tricky to be inserting usages of reload all over the place for this problemipython has special dreload function (not magic functionfor "deep(recursivereloading of modules if were to run import some_lib then type dreload(some_lib)it will attempt to reload some_lib as well as all of its dependencies this will not work in all casesunfortunatelybut when it does it beats having to restart ipython code design tips there' no simple recipe for thisbut here are some high-level principles have found effective in my own work since module or package may be imported in many different places in particular programpython caches module' code the first time it is imported rather than executing the code in the module every time otherwisemodularity and good code organization could potentially cause inefficiency in an application ipythonan interactive computing and development environment www it-ebooks info