[IPython-user] Detecting interactive mode reliably
Wed Feb 28 20:46:00 CST 2007
On 2/28/07, Francesc Altet <email@example.com> wrote:
> I'm trying to discover a way to detect whether the python interpreter
> has been called interactively or not. My goal is to avoid costly
> initialization calls in case the a program is not run interactively.
> To be more specific, I only need to know whether the interpreter has the
> readline() features activated or not. If they are (and only in this
> case) then I need to preload some attributes on certain classe for easy
> interactive introspection (i.e. using the TAB key).
> Anyone has a clue on how to do this? (should be valid for Win as well)
>>> 'readline' in sys.modules
Does that do what you want?
More information about the IPython-user