My approach is this:
I almost never write code at the module level. For example, rather than:
# test.py
print "Hello"
I will use:
# test.py
def test():
print "Hello"
Then, assuming you have a multi-tasking OS, you can open test.py in one
session, and the Python interpreter in another.
First time around:
>>> import test
>>> test.test()
Hello
Oops - you discovered a bug. Switch to test.py, make the changes, then:
>>> reload(test)
<module 'test' or whatever the response is these days!>
>>> test.test()
Hello there
There is no need to start/stop the interpreter each time.
Note, however, that the term "interpreter" can be misleading. The _first_
time Python imports a module, it will "compile" it if necessary. Each
subsequent "import" of the module will _not_ cause a new version to be
parsed and compiled. You must use either the reload() function, or restart
Python itself.
The question of how to interactively debug is slightly different. Assuming
a command line interpreter, you can do something like:
>>> import test
>>> import pdb # the debugger
>>> pdb.call('test.test()')
and a debugging session will start. Fix the code, then:
>>> reload(test)
<blah>
>>> pdb.call('test.test()') # now work with the new code.
If you are using a GUI environment, there will probably be a better debugger
than pdb.
>
> Given that this is probably obvious to every one on this group you
> might want to consider emailing me your response so as not to waste
> bandwidth. Your call. You can estimate this better than me.
My bloody mailer strips all headers, so you mail address is lost on me! Oh,
how I long for the day our Python based Windows mailer/newsreader is ready
:-)
Hope this helps...
Mark.