I would like my script to act differently in an interactive shell session and when running with redirected stdout (for example when piped to some other command).
How
import os, sys os.isatty(sys.stdout.fileno())
or
sys.stdout.isatty()