Search code examples
pythonprintingstderr

print vs stderr


Are there any specific advantages or disadvantages to either print or stderr?


Solution

  • They're just two different things. print generally goes to sys.stdout. It's worth knowing the difference between stdin, stdout, and stderr - they all have their uses.

    In particular, stdout should be used for normal program output, whereas stderr should be reserved only for error messages (abnormal program execution). There are utilities for splitting these streams, which allows users of your code to differentiate between normal output and errors.