# Error messages should not go to standard output, if possible. print('ERROR: We have no cheese at all.', file=sys.stderr) try: f = open('nonexistent-file.xyz', 'rb') except OSError as e: print(e, file=sys.stderr)