<br><tt><font size=2>> Dear list members<br>
> <br>
> I have this python list that represets a sitemap:<br>
> <br>
> tree = [{'indent': 1, 'title':'Item 1', 'hassubfolder':False},<br>
>          {'indent': 1, 'title':'Item 2',
'hassubfolder':False},<br>
>          {'indent': 1, 'title':'Folder 1',
'hassubfolder':True},<br>
>          {'indent': 2, 'title':'Sub Item
1.1', 'hassubfolder':False},<br>
>          {'indent': 2, 'title':'Sub Item
1.2', 'hassubfolder':False},<br>
>          {'indent': 1, 'title':'Item 3',
'hassubfolder':False},<br>
>          {'indent': 1, 'title':'Folder 2',
'hassubfolder':True},<br>
>          {'indent': 2, 'title':'Sub Item
2.1', 'hassubfolder':False},<br>
>          {'indent': 2, 'title':'Folder 2.1',
'hassubfolder':True},<br>
>          {'indent': 3, 'title':'Sub Item
2.1.1', 'hassubfolder':False},<br>
>          {'indent': 3, 'title':'Sub Item
2.1.2', 'hassubfolder':False},<br>
> <br>
> If an item of the list has 'True' for the 'hassubfolder' key than
a new <br>
> "<ul><li>" must be created instead of "</li>"
after its title. (See <br>
> "Folder 2" node in the HTML code above.<br>
</font></tt>
<br><tt><font size=2>Or you can change your list to a dict with a tree
structure and use recursion instead of a stack:</font></tt>
<br><tt><font size=2><br>
tree = [ </font></tt>
<br><tt><font size=2>           
    { 'title': 'Item 1', 'children': [] },  </font></tt>
<br><tt><font size=2>           
    { 'title': 'Item 2', 'children': [] }, </font></tt>
<br><tt><font size=2>           
    { 'title': 'Folder 1', 'children': [ </font></tt>
<br><tt><font size=2>           
               
               
               
    { 'title': 'sub item 1.1',</font></tt>
<br><tt><font size=2>           
               
               
               
      'children' : [],</font></tt>
<br><tt><font size=2>           
               
               
               
    },</font></tt>
<br><tt><font size=2>           
               
               
               
    { 'title': 'Folder 1.1',</font></tt>
<br><tt><font size=2>           
               
               
               
      'children' : [ .. ],</font></tt>
<br><tt><font size=2>           
               
               
               
    },</font></tt>
<br><tt><font size=2>           
               
               
               
    ] }, </font></tt>
<br><tt><font size=2>       ]</font></tt>
<br>
<br>
<br><tt><font size=2>and something like:</font></tt>
<br><tt><font size=2><br>
def displayListItem(i):</font></tt>
<br><tt><font size=2>        print '<li>%s'
% i['title']</font></tt>
<br><tt><font size=2>        if i['children']:</font></tt>
<br><tt><font size=2>           
    print '<ul>'</font></tt>
<br><tt><font size=2>           
    for c in i['children']:</font></tt>
<br><tt><font size=2>           
            displayListItem(c)</font></tt>
<br><tt><font size=2>           
    print '</ul>'</font></tt>
<br><tt><font size=2>        print </li></font></tt>
<br>
<br>
<br><tt><font size=2>you might also use recursion with your existing list,
by 'pop'ing the first item and passing the rest of the list.</font></tt>
<br>
<br><tt><font size=2>Remi</font></tt>
<br>