[IPython-user] Detecting interactive mode reliably

Francesc Altet faltet@carabos....
Fri Mar 2 04:25:33 CST 2007

A Dijous 01 Març 2007 03:46, escriguéreu:
> On 2/28/07, Francesc Altet <faltet@carabos.com> wrote:
> > Hi,
> >
> > 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
> True
> Does that do what you want?

Yes. It does. However, we realized that others IDE environements can use other 
approaches so as to discover attributes (like dir()) without having 
the 'readline' loaded. Oh well, I guess that discovering when auto-completion 
is enabled in a general way is not going to be easy.

Thanks anyway!

>0,0<   Francesc Altet     http://www.carabos.com/
V   V   Cárabos Coop. V.   Enjoy Data

More information about the IPython-user mailing list