Mezgani blog

March 19, 2009

Using pycallgraph

Filed under: python — Tags: , — Ali MEZGANI @ 10:28 pm

Surffing the net i discover a nice tool to create call graph for python programs, it’s pycallgraph.

You can get it using aptitude:

$ sudo aptitude install python-pycallgraph

Let start by the simple example:

class myclass:
def __init__(self, name, color):
self.color=color
self.name=name

def affiche(self):
print(“my name is %s and my color is %s”) % (self.name,self.color)

if __name__==”__main__”:
b=myclass(“banana”,”yellow”)
b.affiche()

And now create a script file named myclass.py with this contenent.
So, we can trace calls for myclass.py as:
$ pycallgraph myclass.py
and the result is so splendid.
pycallgraph

Theme: Silver is the New Black. Blog at WordPress.com.

Follow

Get every new post delivered to your Inbox.