Fredrik Lundh wrote: > Gerard Flanagan wrote: > > > Now I can do this: > > > > page = HtmlPage('Test Page') > > navbar = page.div(id='left').ul(css='navbar') > > for href,link in {'/home':'Home', '/shop':'Shop', > > '/cart':'Cart'}.iteritems(): > > navbar.li.a(link,href=href) > > page.div(id='main').h1('Header').p('<Text Goes Here>') > > > > So *that's* what '__call__' does - I am enlightened! > > just wait until you figure out what iteritems do ;-) > > ::: > > I'm sure you already know it, but dictionaries aren't ordered, so that > navigation bar may not come out as you'd expect. > > >>> {"/home": "Home", "/shop": "Shop", "/cart": "Cart"} > {'/cart': 'Cart', '/shop': 'Shop', '/home': 'Home'} >
Yes, ran into that yesterday! I knew dictionaries weren't ordered but I assumed for simple tests like above, without any additions/deletions, they would 'line up right' - seems that can't be guaranteed. All the best. Gerard -- http://mail.python.org/mailman/listinfo/python-list