Title: Signature.html
It looks like a secondary list should do the trick. I'm not adverse to
keeping one. My list is maybe 30-40 items at most. When I posted
originally, I was just trying to find if I had overlooked something. It
appears that without a secondary list, it gets pretty tricky.
A
Le Fri, 13 Feb 2009 15:41:01 +1300,
John Fouhy a écrit :
> 2009/2/13 Eric Dorsey :
> > Alan, can you give a short snippet of what that would look like? I was
> > trying to code out some idea of how you'd retain insertion order using
> > another dict or a list and didn't get anywhere.
>
> Here's
2009/2/13 Eric Dorsey :
> Alan, can you give a short snippet of what that would look like? I was
> trying to code out some idea of how you'd retain insertion order using
> another dict or a list and didn't get anywhere.
Here's something basic:
class o_dict(dict):
def __init__(self, *args, **
But you need to have an order that will work with sorted().
> Its not just the order you add items to the dict. To store an
> arbitrary order I suspect you would need to maintain a
> secondary list with the keys in the order of insertion.
> The most reliable way to dop that would be to subclas
Le Thu, 12 Feb 2009 09:25:22 -,
"Alan Gauld" a écrit :
> > config_names = {"start_time : '18:00:00', 'gray_scale' : True,
> > "long": 120.00}
> >
> > If I iterate over it, the entries will appear in any order, as
> > opposed to
> > what I see above. However, in the config file, I'd like to
On Thu, Feb 12, 2009 at 4:25 AM, Alan Gauld wrote:
> Thats tricky! Dictionaries are not sorted and do not retain insertion order.
> But you need to have an order that will work with sorted().
> Its not just the order you add items to the dict. To store an
> arbitrary order I suspect you would ne
On Thu, Feb 12, 2009 at 2:55 PM, Alan Gauld wrote:
> But you need to have an order that will work with sorted().
> Its not just the order you add items to the dict.
And yes algorithmically, there is No Requirement or I should say a
good Use Case for a Dict to have sorted keys. More we work with
"Eric Dorsey" wrote
config_names
{'start_time': '18:00:00', 'gray_scale': True, 'long': 120.0}
for i, x in config_names.items():
... print i, x
...
start_time 18:00:00
gray_scale True
long 120.0
Thats pretty much a happy coincidence, there is no guarantee
that it will work like that
"Wayne Watson" wrote
config_names = {"start_time : '18:00:00', 'gray_scale' : True,
"long": 120.00}
If I iterate over it, the entries will appear in any order, as
opposed to
what I see above. However, in the config file, I'd like to keep them
in the order above.
Thats tricky! Dictionaries
Looks good. Thanks.
Eric Dorsey wrote:
>>> config_names = {'start_time': '18:00:00',
'gray_scale': True, 'long': 120.0}
>>> config_names
{'start_time': '18:00:00', 'gray_scale': True, 'long': 120.0}
>>> for i, x in config_names.items():
... print i, x
...
start_t
>>> config_names = {'start_time': '18:00:00', 'gray_scale': True, 'long':
120.0}
>>> config_names
{'start_time': '18:00:00', 'gray_scale': True, 'long': 120.0}
>>> for i, x in config_names.items():
... print i, x
...
start_time 18:00:00
gray_scale True
long 120.0
>>>
On Wed, Feb 11, 2009 at 7
Title: Signature.html
I have a dictionary that looks like:
config_names = {"start_time : '18:00:00', 'gray_scale' : True, "long":
120.00}
If I iterate over it, the entries will appear in any order, as opposed
to what I see above. However, in the config file, I'd like to keep them
in the order
12 matches
Mail list logo