Created
August 4, 2016 17:43
-
-
Save akaptur/0bddb84b53bd4299b84eb736dd126636 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
>>> import sys | |
>>> def stuff(): | |
... print("calling stuff!") | |
... | |
>>> def printer(frame, event, arg): | |
... print(frame, event, arg) | |
... return printer # return itself to keep tracing | |
... | |
>>> sys.settrace(printer) # register the tracing function | |
>>> stuff() | |
(<frame object at 0x10d3625c0>, 'call', None) | |
(<frame object at 0x10d3625c0>, 'line', None) | |
(<frame object at 0x10d3625c0>, 'return', (u'stuff()\n', 8)) | |
(<frame object at 0x10d259050>, 'call', None) | |
(<frame object at 0x10d259050>, 'line', None) | |
(<frame object at 0x10d259898>, 'call', None) | |
(<frame object at 0x10d259898>, 'line', None) | |
calling stuff! | |
(<frame object at 0x10d259898>, 'return', None) | |
(<frame object at 0x10d259050>, 'return', None) | |
>>> sys.settrace(None) # turn it off | |
(<frame object at 0x10d3625c0>, 'call', None) | |
(<frame object at 0x10d3625c0>, 'line', None) | |
(<frame object at 0x10d3625c0>, 'return', (u'sys.settrace(None) # turn it off\n', 34)) | |
(<frame object at 0x10d351a70>, 'call', None) | |
(<frame object at 0x10d351a70>, 'line', None) | |
>>> print('hi') # tracing is done | |
hi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment