Created
May 18, 2013 03:20
-
-
Save draftcode/5603107 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| # -*- 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