check if running under IDLE

Bob Gailer bgailer at alum.rpi.edu
Wed Aug 6 18:31:27 CEST 2003


At 11:48 AM 8/6/2003 +0200, Helmut Jarausch wrote:
[snip][
To check a script accessing sys.argv I have to set it.
>Unfortunately the 'Run' pulldown menu of IDLE doesn't have an item
>to set sys.argv as it's common with debuggers for C.
>
>Now in Python I can set  sys.argv within the script,
>but forgetting to comment this out afterwards makes the
>script wrong outside of IDLE
>
>So I'd like to say
>
>if __IDLE_IS_RUNNUNG__:
>   sys.argv=['test','-a','/home/jarausch/BackUp']
>
>but I haven't work how to check if the script is running under IDLE's 
>supervision.

import sys
__IDLE_IS_RUNNUNG__ = len(sys.modules) > 20

Bob Gailer
bgailer at alum.rpi.edu
303 442 2625
-------------- next part --------------

---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.506 / Virus Database: 303 - Release Date: 8/1/2003


More information about the Python-list mailing list