Skip to content

Instantly share code, notes, and snippets.

@mborgerson
Created March 9, 2022 07:56
Show Gist options
  • Save mborgerson/fa5238797891c045b5412f7ecc99c398 to your computer and use it in GitHub Desktop.
Save mborgerson/fa5238797891c045b5412f7ecc99c398 to your computer and use it in GitHub Desktop.
Find Python print culprit
# Hook the `print` built-in to find out where a print statement is coming from
import inspect
_print = print
def print(*vargs, **kwargs):
s = inspect.stack()[1]
_print(f'Printing from {s.filename}:{s.lineno}')
_print(*vargs, **kwargs)
import builtins
builtins.print = print
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment