[Pythonmac-SIG] Running a script "from scratch" from the IDE

Just van Rossum just@letterror.com
Thu, 7 Sep 2000 14:01:05 +0100


At 10:37 AM +0200 07-09-2000, Jack Jansen wrote:
>> I often find that I want to run a script "from scratch" form the IDE.
>> What I mean is that is should run EXACTLY the same as it would if
>> dropped on the interpreter. All old references to variable will be gone,
>> all files closed, and all moduled reloaded (even nested modules).
>>
>> Is it possible to do this?
>
>The only reasonable way to do this would be to have the IDE fire up a Python
>interpreter. That would also solve the Tk problem, by the way.
>
>There's been some discussion on this (don't remember whether it was on the
>list or a private exchange between Just and me) but I don't remember whether
>actual code was written.

I started writing some code but then realized it's not as easy as it
sounds. The main problem is that the plain interpreter doesn't respond to
quit events, so you would have to quit it manually each time if there was a
traceback. Or write YetAnotherWrapperAppletThatTakesCareOfThis. Ugh.

The other problem was that I was too lazy to figure out how to implement
something like this:

   findertools.launch(<interpreter_app>, <file[s]_to_launch_it_with>)

(It's important to be able to specify the exact app, otherwise you'll get
strange behavior when you have multiple versions installed)

It needs to perform these steps:

- find out where the interpreter app is
- if the interpreter is still running: quit it
- check whether script is saved
- ask for save if not
- launch interpreter with script file

I wrote the UI part (ie. another menu item in the script popup menu: "Run
with Interpreter"), but then gave up when I realized how much work the
actual functionality was...

Just