Skip to content

Instantly share code, notes, and snippets.

@simonLeary42
Last active June 23, 2023 02:17
Show Gist options
  • Save simonLeary42/d11de6997a7f857466e9cb4ba7caef22 to your computer and use it in GitHub Desktop.
Save simonLeary42/d11de6997a7f857466e9cb4ba7caef22 to your computer and use it in GitHub Desktop.
# print to stderr. If stderr is a TTY, print in red
def print_err(*args, **kwargs):
if sys.stderr.isatty():
print('\033[1;31m', end='', file=sys.stderr)
print(*args, **kwargs, file=sys.stderr)
if sys.stderr.isatty():
print('\033[0m', end='', file=sys.stderr)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment