Why use `logging` instead of `print`?
BeginnerConceptExceptions, context managers, files & logging
Answer
logging gives you levels (DEBUG, INFO, WARNING, ERROR, CRITICAL) you can change without editing code, timestamps and logger names, output to stderr so stdout stays clean for data, handlers for files/syslog/JSON, and library logs (boto3, urllib3) in the same stream. print gives none of that and mixes diagnostics with the report a pipeline might be parsing.
More on Exceptions, context managers, files & logging
How does `try` / `except` / `else` / `finally` work?BeginnerWhy is a bare `except:` (or `except Exception: pass`) dangerous?BeginnerWhat is exception chaining, and what is `raise ... from`?IntermediateWhen should you define custom exception classes?IntermediateWhat is the EAFP vs LBYL style, and which does Python prefer?IntermediateHow does a `with` statement work, and why use it for files?Beginner