Detecting interactive mode reliably
matthew at barnes.net
Mon Sep 8 17:45:51 CEST 2003
Surely this has been asked before, but I've not yet found the answer
on Google Groups or the Python FAQ.
Is there a method for reliably detecting whether the interpreter is
running in interactive mode? The best solution I've come up with so
far is to check sys.argv for an empty string or '-c', but I'm not
sure whether that works for all the various Python IDEs out there.
Reason for the question is that I'd like a module I'm writing to run
some extra initialization steps when the module is imported from an
So something like:
More information about the Python-list