Re: Tree data structure with: single, double and triple children option along with AVM data at each node

2011-11-24 Thread Miki Tebeka
There a many ways to do this, here's one: from collections import namedtuple Tree = namedtuple('Tree', ['feature', 'children']) t = Tree(1, [Tree('hello', []), Tree(3, [])]) -- http://mail.python.org/mailman/listinfo/python-list

Re: tree data structure

2005-03-26 Thread runsun pan
couple of links for python tree: http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/217212 http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/201423 http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/305313 http://www.rexx.com/~dkuhlman/ -- http://mail.python.org/mailman/listinfo/

Re: tree data structure

2005-03-25 Thread Mike Rovner
vivek khurana wrote: i am a new member on this list. I have to implement tree data structure using python. How it can be done in python. Is there an existing data structure which can be used as tree? I have searched archives and manuals but no luck. You can start with Guido's essay http://python

Re: tree data structure

2005-03-25 Thread Satchidanand Haridas
Hi, You could use Python dictionaries as trees. Example: to represent a simple tree: 'a' <- ( 'b' , 'c' ) 'b' <- ( 'd', 'e', 'f') 'e' <- ( 'g') 'f' <- ('h', 'i', 'j') treeD = { 'a' : ( { 'b' : ( 'd',

Re: tree data structure

2005-03-25 Thread Dan Bishop
vivek khurana wrote: > Hi! all > > i am a new member on this list. I have to implement > tree data structure using python. How it can be done > in python. Is there an existing data structure which > can be used as tree? Tuples can be used as trees: you can let them represent (data, left_child, rig