need dict to maintain order

rihad rihad at mail.ru
Fri Jan 18 11:28:27 EST 2002


Hi there, I'm trying to automate the process of creating so called
`webpage navbars' by writing an offline python script, but dict
doesn't seem to give its items in defined order:

links = {'index.html': 'Home', 'file0.html': 'Some foo'}

this results in 
<div class="navbar_horz">
[<a href="file0.html">Some foo</a>
 | <a href="index.html">Home</a>
]
</div>

which is backwards. And yes, I'm using 

link, caption = links.popitem()

Which other type would you recommend?

Thanks in advance for any help.




More information about the Python-list mailing list