Why are there no ordered dictionaries?

Fredrik Lundh fredrik at pythonware.com
Sun Nov 20 08:58:00 EST 2005


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', {....})]

</F> 






More information about the Python-list mailing list