Skip to content

Instantly share code, notes, and snippets.

@AdityaSoni19031997
Created October 27, 2018 08:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save AdityaSoni19031997/5416a519d582b2f08f8b80141033afc8 to your computer and use it in GitHub Desktop.
Save AdityaSoni19031997/5416a519d582b2f08f8b80141033afc8 to your computer and use it in GitHub Desktop.
#!/usr/bin/env python
# encoding: utf-8
import sys
def trace_calls_and_returns(frame, event, arg):
co = frame.f_code
func_name = co.co_name
if func_name == 'write':
# Ignore write() calls from print statements
return
filename = co.co_filename
if event == 'call':
print f'(func_name , filename)
return trace_calls_and_returns
return
sys.settrace(trace_calls_and_returns)
#your function call will now generate a huge output to indicate what all did it called (it will be a huge and will be default for every
#function call there onwards)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment