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

Steven D'Aprano steve+comp.lang.python at pearwood.info
Fri Apr 5 09:37:43 EDT 2013


On Fri, 05 Apr 2013 07:04:35 -0400, Dave Angel wrote:

> On 04/05/2013 05:30 AM, Steven D'Aprano wrote:
>> (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.
[...]
>> Ideally, I'd like to detect any arbitrary environment such as Spyder,
>> IPython, BPython, etc., but will settle for just IDLE.
>
> Are you open to OS-specific techniques?  For example, on Linux, you
> could learn things from ps aux.

I'd prefer a pure-Python solution, but if the choice is between an 
accurate solution using an external tool, and an inaccurate Python 
heuristic, I'm willing to use external tools.



-- 
Steven



More information about the Python-list mailing list