command line or idle?

Alex Martelli aleax at aleax.it
Tue Sep 23 09:53:24 EDT 2003


sjf wrote:

> Is it possible to distinguish if script is running on python command line
> (python.exe) or IDLE?

Not in entirely reliable way, but there are many hints you can generally
rely on.  For example, in the IDLE "Python Shell" sys.stdout is an
instance of idlelib.rpc.RPCProxy (in IDLE 1.0) -- that MIGHT happen
even "on python command line", of course, but it is not very likely to.


Alex





More information about the Python-list mailing list