35 lines
1.2 KiB
Plaintext
35 lines
1.2 KiB
Plaintext
From: neilh at fast.fujitsu.com.au (Neil Hodgson)
|
|
Date: Mon, 12 Apr 1999 19:11:18 +1000
|
|
Subject: OrderedDict.py
|
|
References: <Pine.GSO.3.96.990409180912.20801E-100000@crusoe.crusoe.net>
|
|
Message-ID: <3711B8B6.9F0D55C7@fast.fujitsu.com.au>
|
|
X-UID: 1257
|
|
|
|
evil Japh (or possibly his good twin Jeff Pinyan) wrote:
|
|
|
|
> Is there a need for a module which allows for ordered processing of an
|
|
> dictionary?
|
|
|
|
I think there is a need for this. There is a bit of code I wrote for
|
|
PythonWin where some values are displayed in a UI and then read back in
|
|
after user modification. It did not matter what order the dictionary was
|
|
displayed in so long as it could be read back in in the same order to
|
|
match up. Nothing in the documentation specifies that asking for the
|
|
elements (or keys) of a dictionary returns elements (or keys) in the
|
|
same order each time, even if no modifications are done to the
|
|
dictionary between accesses. Therefore, each time the dictionary was
|
|
used, there was a sequence like:
|
|
|
|
sortedkeys = formats.keys()
|
|
sortedkeys.sort()
|
|
for f in sortedkeys:
|
|
|
|
Your module may have made this code easier and also clearer.
|
|
|
|
Neil Hodgson
|
|
Fujitsu Australia Software Technology
|
|
|
|
|
|
|
|
|