471,079 Members | 961 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,079 software developers and data experts.

Dictionaries autosorting

micmast
144 100+
hey,

it is possible to make sure that a given dictionary stays the same way?
for example
Expand|Select|Wrap|Line Numbers
  1. options = { 'Something':'value','abc':'value' }
  2.  
this should stay the same and not switch like this:
Expand|Select|Wrap|Line Numbers
  1. >>> options = { 'Something':'value','abc':'value' }
  2. >>> print options
  3. {'abc': 'value', 'Something': 'value'}
  4. >>> 
  5.  
  6.  
Mar 31 '08 #1
1 1051
jlm699
314 100+
If you use pythonutils you can implement an OrderedDict(), which I've used many times in my scripts. It works exactly like a dictionary, except you initialize it like
Expand|Select|Wrap|Line Numbers
  1. od = OrderedDict()
Mar 31 '08 #2

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

7 posts views Thread by Kerry Neilson | last post: by
reply views Thread by Till Plewe | last post: by
8 posts views Thread by Frohnhofer, James | last post: by
3 posts views Thread by Shivram U | last post: by
210 posts views Thread by Christoph Zwerschke | last post: by
2 posts views Thread by David Pratt | last post: by
3 posts views Thread by Faisal Alquaddoomi | last post: by
8 posts views Thread by placid | last post: by
1 post views Thread by Edwin.Madari | last post: by
14 posts views Thread by cnb | last post: by
reply views Thread by leo001 | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.