How to tell if interpreter is in interactive mode

Thomas Heller thomas.heller at ion-tof.com
Fri Jun 22 05:25:59 EDT 2001


"Alex Martelli" <aleaxit at yahoo.com> wrote in message news:9gl7ba07u8 at enews2.newsguy.com...
[John Copella asked how to tell if interpreter is in interactive mode]
>
> It IS pretty easy -- sorry, hadn't noticed your question earlier!
> Hoping the answer is still of interest despite the 5 days since
> you asked...:
>
> In module sys, an attribute named ps1 exists during interactive
> interpreter sessions.  IDE's such as IDLE and PythonWin also set
> it (it's normally the string ">>> ").  This attribute is *NOT* set
> if the interpreter is NOT interactive.
>

The only catch is that this attribute is not yet
defined when sitecustomize is imported.

Any other solutions?

Thomas





More information about the Python-list mailing list