On Tue, Aug 11, 2015 at 10:29:56AM +0200, jarod_v6--- via Tutor wrote: > HI there!! > I try to develop some scripts. I use ipython for check if my script work. > > When I change the script and try to import again that script I'm not > able to see the modification so I need every time close ipython and > run again and import the script. How can do the refresh of library > without close ipython? thanks so much!
In Python 2: import mymodule # make some changes reload(mymodule) But be careful that objects attached to the module are *not* updated to use the new module! import mymodule x = mymodule.MyClass() reload(mymodule) x.method() x still uses the old version of the class and method, and will *not* use the new one. You have to throw it away and start again: reload(mymodule) x = mymodule.MyClass() x.method() Now you will see the new behaviour. In Python 3, everything is the same except you have to do: from imp import reload first. -- Steve _______________________________________________ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor