To import a script from IDLE you can do:
>>> import os >>> os.chdir('C:\\Users\\You\\Some\\Arbitrary\\Path') >>> import scriptname
Keep in mind that you will need to call constructors with a scriptname. prepended e.g. scriptname.myClass(...)
If you changed something in the script, you need to reload it as follows:
>>> import imp >>> imp.reload(scriptname)
(There is an easier way if you just want to play with types from a single script, and if the script contains only definitions of functions and classes (without running code). Then you can simply open the script in IDLE and go to Run>Run Module . When you use this method, there is no need to put scriptname. before the constructors.)
lambda343
source share