REPOST: Re: Finding out that Python is in interactive mode in sitecustomize.py

Joonas Paalasmaa joonas at olen.to
Fri Dec 28 17:43:16 EST 2001


Carey Evans <careye at spamcop.net> wrote in message news:<87g05wgq84.fsf at psyche.dnsalias.org>...
> Joonas Paalasmaa <joonas at olen.to> writes:
> 
> > How can I find out that Python is started in interactive mode in
> > sitecustomize.py ?
> 
> A search on http://groups.google.com/ for "python test interactive"
> comes up with this as the second result:
> 
>     import sys
>     if hasattr(sys, "ps1"):
>         # probably interactive
>     else:
>         # probably not interactive

For some reason it doesn't work in sitecustomize.py .
When these lines are to sitecustomize.py and Python is started in
interactive mode, Python prints "In non-interactive mode".

# the lines
import sys
if hasattr(sys, "ps1"):
    print "In interactive mode"
else:
    print "In non-interactive mode"

========= WAS CANCELLED BY =======:
Path: news.sol.net!spool1-nwblwi.newsops.execpc.com!newsfeeds.sol.net!news-out.visi.com!hermes.visi.com!out.nntp.be!propagator-SanJose!in.nntp.be!news-in-sanjose!news-xfer.nuri.net!feeder.kornet.net!news1.kornet.net!ua4canc3ll3r
From: joonas at olen.to (Joonas Paalasmaa)
Newsgroups: comp.lang.python
Subject: cmsg cancel <11aed8f9.0112281443.afbc668 at posting.google.com>
Control: cancel <11aed8f9.0112281443.afbc668 at posting.google.com>
Date: Mon, 31 Dec 2001 03:18:31 GMT
Organization: A poorly-installed InterNetNews site
Lines: 2
Message-ID: <cancel.11aed8f9.0112281443.afbc668 at posting.google.com>
NNTP-Posting-Host: 211.57.49.2
X-Trace: news2.kornet.net 1009775001 27193 211.57.49.2 (31 Dec 2001 05:03:21 GMT)
X-Complaints-To: usenet at news2.kornet.net
NNTP-Posting-Date: Mon, 31 Dec 2001 05:03:21 +0000 (UTC)
X-No-Archive: yes
X-Unac4ncel: yes
X-Commentary: I love NewsAgent 1.10 and the Sandblaster Cancel Engine Build 74 (19 March 1999)

This message was cancelled from within Mozilla.



More information about the Python-list mailing list