Skip to content

Instantly share code, notes, and snippets.

@antocuni
Created July 14, 2023 14:35
Show Gist options
  • Save antocuni/4920643fade57a03456f25c9a3450dde to your computer and use it in GitHub Desktop.
Save antocuni/4920643fade57a03456f25c9a3450dde to your computer and use it in GitHub Desktop.
fakepdb
import sys
def main():
myvar = 'hello'
print('this is line 5')
print('this is line 6')
print('this is line 7')
print('this is line 8')
print('this is line 9')
def fakepdb(frame, event, arg):
if event == 'line':
print(' about to execute line', frame.f_lineno)
if frame.f_lineno == 7:
print('welcome to fakepdb: type "c" to continue, or the name of '
'a variable to print it')
while True:
cmd = input('(fakepdb) ')
if cmd == 'c':
break
else:
v = frame.f_locals.get(cmd, f'variable {cmd} not found')
print(v)
return fakepdb # continue tracing
if __name__ == '__main__':
sys.settrace(fakepdb)
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment