if __name__ == "__main__": import types import gv g = gv.digraph('types') gv.setv(g, 'overlap', 'false') gv.setv(g, 'splines', 'true') for item in dir(__builtins__): attr = getattr(__builtins__, item) if type(attr) is types.TypeType and \ not issubclass(attr, BaseException): tail = None head = None for i in attr.__mro__: nodename = i.__name__ tail = gv.findnode(g, nodename) if not tail: tail = gv.node(g, nodename) if head and not gv.findedge(tail, head): gv.edge(tail, head) head = tail gv.layout(g, 'neato') gv.render(g, 'png', 'built-in_types.png')
執行完畢之後,將會在程式同一路徑下產生一個檔名為built-in_types的PNG檔。
從這張圖可以看到所有的型別都是繼承至object類別。
###
沒有留言:
張貼留言