[New-bugs-announce] [issue5579] Display for OrderedDict

Todd Weiler report at bugs.python.org
Fri Mar 27 15:54:19 CET 2009

New submission from Todd Weiler <tweiler at raggedcreek.com>:

Now that python has an ordered dictionary it would be great to have a
display sytax for creating them.

To create a dict I just use the dict display syntax:
newdict = {'fred':'flintstone', 'barney':'rubble', 'dino':'thedinosaur'}

I'd like to be able to create an OrderedDict in the same way - I realize
that a list of tuples would do the trick, but I find the dict display
more convenient and readable.  Back in the archives there is probably a
whole discussion of why dict displays are useful.  My reason for liking
displays is that I like to put dictionaries inside dictionaries - the
display format spread out over several lines makes this easy to read.

Possible solutions:

1. maybe use ^{ for OrderedDicts
newdict = ^{'fred':'flintstone', 'barney':'rubble', 'dino':'thedinosaur'}

2. have OrdredDict accept a dictionary display string
newodict = OrderedDict("{'fred':'flintstone', 'barney':'rubble',

messages: 84261
nosy: tweiler
severity: normal
status: open
title: Display for OrderedDict
type: feature request
versions: Python 3.1

Python tracker <report at bugs.python.org>

More information about the New-bugs-announce mailing list