[Tutor] building nonbinary trees

Alan Gauld alan.gauld at freenet.co.uk
Fri Nov 18 06:30:53 CET 2005


> I'v got a start but I'm stuck because I don't understand how to call  
> a tree's nodes by name.

Every time you see call by name, think dictionary.

class Node:
     def __init__(self):
         self.children = {}
     def addChild(self,child,name):
         self.children[name] = child
     etc...

HTH,

Alan G.


More information about the Tutor mailing list