By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
443,898 Members | 1,183 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 443,898 IT Pros & Developers. It's quick & easy.

Dictionaries autosorting

micmast
100+
P: 144
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
Share this Question
Share on Google+
1 Reply


jlm699
100+
P: 314
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.