Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > Re: check if running under IDLE

Reply
Thread Tools

Re: check if running under IDLE

 
 
Helmut Jarausch
Guest
Posts: n/a
 
      08-07-2003
Bob Gailer wrote:
> 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
>


Thanks for this idea. Just to report
a simple script

#!/usr/local/bin/python
import sys
print len(sys.modules)

prints 26 here (Python 2.3)

while under idle I get 117
so
__IDLE_IS_RUNNUNG__ = len(sys.modules) > 100

seems to be safe.

Helmut.

--
Helmut Jarausch

Lehrstuhl fuer Numerische Mathematik
RWTH - Aachen University
D 52056 Aachen, Germany

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
IDLE - Python 3.1 running under XP SP3 - newline error Badger_1610 Python 2 09-01-2010 10:03 AM
A router running under WinXP runs under Windows Vista too? Peter Wagner Wireless Networking 12 02-04-2008 11:02 PM
Why does Rpy/R-plot work under PythonWin, but not under commandline/IDLE? Bo Peng Python 1 01-09-2006 07:05 AM
help : my jar file is not running under linux terminal , but it runs under JbuilderX ide bronby Java 1 07-15-2005 07:23 AM
Java application developped under Linux running ridiculously slow under Windows hshdude Java 12 11-04-2004 05:49 PM



Advertisments