Add sys.IsTty() to detect if something is a tty or not.