Why are there no ordered dictionaries?

bonono at gmail.com bonono at gmail.com
Sun Nov 20 09:11:53 EST 2005


Fredrik Lundh wrote:
> bonono at gmail.com wrote:
>
> > I am writing a web applications(simple forms) which has a number of
> > fields. Each field naturally has a name and a number of
> > attributes(formatting etc.), like this :
> >
> > d = {'a':{...}, 'b':{....}}
> >
> > This dict would be passed to the Kid template system which would lay it
> > out into a HTML form. For quick and dirty forms, I don't want to code
> > each field individually in the HTML template but just from top to
> > bottom(or left to right for a table) with a for loop.
> >
> > However, I still want to group certain fields together. This is my need
> > of an ordered dict.
>
> huh?  if you want a list, use a list.
>
>     d = [('a', {...}), ('b', {....})]
>
Didn't I say that for quick and dirty form(usually first draft), I want
a list ? But the same template, it would(may) be further enhanced by
graphic designers in which case, I need direct access to the field
names, thus the dict property.

In this way, I don't have to change the python code just because I
change the presentation in the template.




More information about the Python-list mailing list