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

Carey Evans careye at spamcop.net
Sun Dec 30 03:46:02 EST 2001


joonas at olen.to (Joonas Paalasmaa) writes:

> 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".

[...]

Looking closer, it looks like sys.ps1 is set up just before the
interactive loop is started, but after sitecustomize.py is imported.

Given this, the easiest solution looks like the PYTHONSTARTUP
environment variable.  The file this points to is only executed for an
interactive session.  You could set this for all users in a global
shell startup file, or just set it from sitecustomize.py:

  import os
  os.environ['PYTHONSTARTUP'] = '/path/to/interactive_startup.py'

-- 
	 Carey Evans  http://home.clear.net.nz/pages/c.evans/

========= WAS CANCELLED BY =======:
Path: news.sol.net!spool0-nwblwi.newsops.execpc.com!newsfeeds.sol.net!news-out.visi.com!hermes.visi.com!news.maxwell.syr.edu!feeder.kornet.net!news1.kornet.net!ua4canc3ll3r
From: Carey Evans <careye at spamcop.net>
Newsgroups: comp.lang.python
Subject: cmsg cancel <87k7v5ksdx.fsf at psyche.dnsalias.org>
Control: cancel <87k7v5ksdx.fsf at psyche.dnsalias.org>
Date: Mon, 31 Dec 2001 02:42:05 GMT
Organization: A poorly-installed InterNetNews site
Lines: 2
Message-ID: <cancel.87k7v5ksdx.fsf at psyche.dnsalias.org>
NNTP-Posting-Host: 211.57.49.2
X-Trace: news2.kornet.net 1009774308 27193 211.57.49.2 (31 Dec 2001 04:51:48 GMT)
X-Complaints-To: usenet at news2.kornet.net
NNTP-Posting-Date: Mon, 31 Dec 2001 04:51:48 +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