Skip to content

Instantly share code, notes, and snippets.

@draftcode
Created May 18, 2013 03:20
Show Gist options
  • Select an option

  • Save draftcode/5603107 to your computer and use it in GitHub Desktop.

Select an option

Save draftcode/5603107 to your computer and use it in GitHub Desktop.
# -*- coding: utf-8 -*-
from __future__ import division, absolute_import, print_function, unicode_literals
import sys
def tracer(frame, event, arg):
print("source: {}\tlineno: {}".format(frame.f_code.co_filename, frame.f_lineno))
with open(frame.f_code.co_filename, 'r') as f:
print(f.readlines()[frame.f_lineno-1][0:-1])
return tracer
sys.settrace(tracer)
def fib(n):
ret = None
if n == 0 or n == 1:
ret = n
else:
ret = fib(n-1) + fib(n-2)
return ret
print(fib(5))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment