Python Call Graph
Basic
A simple Python example with two classes.
Source Code
#!/usr/bin/env python
'''
This example demonstrates a simple use of pycallgraph.
'''
from pycallgraph import PyCallGraph
from pycallgraph.output import GraphvizOutput
class Banana:
def eat(se...
Basic
A simple Python example with two classes.
Source Code
#!/usr/bin/env python
'''
This example demonstrates a simple use of pycallgraph.
'''
from pycallgraph import PyCallGraph
from pycallgraph.output import GraphvizOutput
class Banana:
def eat(self):
pass
class Person:
def __init__(self):
self.no_bananas()
def no_bananas(self):
self.bananas = []
def add_banana(self, banana):
self.bananas.append(banana)
def eat_bananas(self):
[banana.eat() for banana in self.bananas]
self.no_bananas()
def main():
graphviz = GraphvizOutput()
graphviz.output_file = 'basic.png'
with PyCallGraph(output=graphviz):
person = Person()
for a in xrange(10):
person.add_banana(Banana())
person.eat_bananas()
if __name__ == '__main__':
main()
Basic — Python Call Graph 1.0.1 documentation http://pycallgraph.slowchop.com/en/master/examples/basic...
1 of 2 2014/1/4 20:58
Generated Image
Below is the generated image from the code above. If you’re having issues with the image
below, try the direct link to image.
Basic — Python Call Graph 1.0.1 documentation http://pycallgraph.slowchop.com/en/master/examples/basic...
2 of 2 2014/1/4 20:58
本文档为【Python Call Graph】,请使用软件OFFICE或WPS软件打开。作品中的文字与图均可以修改和编辑,
图片更改请在作品中右键图片并更换,文字修改请直接点击文字进行修改,也可以新增和删除文档中的内容。
[版权声明] 本站所有资料为用户分享产生,若发现您的权利被侵害,请联系客服邮件isharekefu@iask.cn,我们尽快处理。
本作品所展示的图片、画像、字体、音乐的版权可能需版权方额外授权,请谨慎使用。
网站提供的党政主题相关内容(国旗、国徽、党徽..)目的在于配合国家政策宣传,仅限个人学习分享使用,禁止用于任何广告和商用目的。