I have some code in a module that I need to run only when the interpreter is running interactively. Is there any way to test for this at run time? I have looked at sys.stdin.isatty(), but this returns 1 when running non-interactively as well (unless you do something odd like redirect stdin to /dev/null). Thanks in advance, John