Using pycallgraph

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

Using pycallgraph

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s