How do I tell if I'm running under IDLE?

Mark Janssen dreamingforward at gmail.com
Sat Apr 6 20:35:32 EDT 2013


> (Apologies in advance if you get multiple copies of this. My Usenet
> connection seems to be having a conniption fit at the moment.)
>
> I'm looking for an official way to tell what interpreter (if any) is
> running, or at least a not-too-horrible unofficial way.

I was going to work on this IDLE TODO myself, but haven't got around
to it.  I think the best way is to use the tempfile module (to be
clear this is a fix within IDLE itself).

This is the whole procedure that should be necessary:

1) At IDLE startup check to see if there is an existing idle tempfile
and delete it, if so.
2) Create an IDLE temp file.
3) At IDLE shutdown, delete prior tempfile.

Now if anyone wants to see if IDLE is running, they only need to check
to see if the tempfile exists.

Hope that helps.  If you implement it, you can take the item off the
IDLE todo list too.

MarkJ
Tacoma, Washington



More information about the Python-list mailing list