/
examples.py
40 lines (32 loc) · 996 Bytes
/
examples.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# -*- coding: utf-8 -*-
""" Pytrace, a tool to trace function calls/returns.
Some examples.
Author: Julien Delplanque (julien.delplanque@live.be)
Repository: https://github.com/juliendelplanque/pytrace
License: GNU GENERAL PUBLIC LICENSE Version 2
"""
from pytrace import function_to_trace, set_call_string, set_return_string
def count(n):
if n == 0:
return n
else:
count(n-1)
return n
def fibo(n):
if n == 0:
return 0
elif n == 1:
return 1
else:
return fibo(n-2)+fibo(n-1)
if __name__ == '__main__':
print("Example with count function")
print("===========================")
function_to_trace(count)
count(5)
print("\nExample with fibo function")
print("==========================")
set_call_string("-->") # Change the string used to represent function calls.
set_return_string("o<-") # Change the string used to represent returns.
function_to_trace(fibo)
fibo(4)