Finding out that Python is in interactive mode in sitecustomize.py
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
> # 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
if hasattr(sys, "ps1"):
print "In interactive mode"
print "In non-interactive mode"
More information about the Python-list