Re: One Really Important Suggestion

Guido van Rossum (Guido.van.Rossum@cwi.nl)
Thu, 02 Jul 1992 17:05:22 +0200

>Not to be critical, but since python is an interpreted language , a
^^^^^^^^^^^
>key asset of such a language would be to re-import modules and be able
>to test the methods out that I just changed.

I suppose you meant "interactive" there?

>It would speed up incremental development much more if I did not have
>to exit the interpreter each time I wanted to retest an altered
>module.

You don't have to. Look at the description of the built-in function
'reload()'. There are some restrictions, but if you are working on a
single it is often what you need.

>However, I guess an alternate solution is to run the source from the
>shell instead of import module and the module.method()

If you have GNU Emacs, and are using the Python mode provided with the
Python distribution (misc/python-mode.el), you can use C-c C-c in a
Python buffer to run the current buffer through the interpreter. You
can also start an interactive Python interpreter in another window
with C-c !; C-c C-c will then send the buffer as input to that
interpreter. See the mode-specific info for more hints.

Finally, the '-c statements' command line option to the interpreter is
sometimes useful, especially if your shell has a fast way of repeating
the last command (e.g. csh '!!' or ksh 'r').

--Guido van Rossum, CWI, Amsterdam <guido@cwi.nl>
"It's a bit runny, sir"