check if running under IDLE

Peter Abel p-abel at
Tue Aug 5 22:37:09 CEST 2003

Helmut Jarausch <jarausch at> wrote in message news:<3f2ec16b$0$285$ba620e4c at>...
> Hi,
> I'd like to check a script which needs sys.argv
> I haven't seen a method to set this when running the script
> in IDLE's shell or editor window.
> The only way I've found is to assign (test values)
> to sys.argv but only if the script is running under IDLE
> Is there a mean either to set sys.argv without modifying
> the script or to check if the script is running under IDLE's
> control.
> Thanks for a hint,
> Helmut Jarausch
> Lehrstuhl fuer Numerische Mathematik
> RWTH - Aachen University
> D 52056 Aachen, Germany

I doen't think that your problem is to know if
you're running under Idle or PythonWin or Pythonshell
or ..
I think your problem is to know if there are command line
parameters passed to your script or not. And this is simply
done by:
if len(sys.argv) > 1:
  do_something_else_with_explicit(['Para_1','Para_2', ... ,'Para_Last']

Hope I'm not wrong.

More information about the Python-list mailing list