Hallo,
I am new to python, and I am trying to do something that I am used to do in PHP (so the promlem may be conceptional) and search quite a lot in google, but :-( no efect
I have configuration file with something like that
MENU_ELEMENTS = {
'menu1': {'id': '10', 'name': 'Some name'},
'menu2': {'id': '11', 'name': 'Some other name'},
'menu3': {'id': '12', 'name': 'Some other other name'},
}
I want to iterate them in the order I put them in, but the result always is the same without the order I put them
I use
>>> MENU_ELEMENTS = {
... 'menu2': {'id': '11', 'name': 'Some other name'},
... 'menu1': {'id': '10', 'name': 'Some name'},
... 'menu3': {'id': '12', 'name': 'Some other other name'},
... }
>>> for MENU_ELEMENT_K, MENU_ELEMENT_V in MENU_ELEMENTS.iteritems():
... print MENU_ELEMENT_K, MENU_ELEMENT_V
...
menu2 {'id': '11', 'name': 'Some other name'}
menu3 {'id': '12', 'name': 'Some other other name'}
menu1 {'id': '10', 'name': 'Some name'}
>>> MENU_ELEMENTS = {
... 'menu1': {'id': '10', 'name': 'Some name'},
... 'menu2': {'id': '11', 'name': 'Some other name'},
... 'menu3': {'id': '12', 'name': 'Some other other name'},
... }
>>> for MENU_ELEMENT_K, MENU_ELEMENT_V in MENU_ELEMENTS.iteritems():
... print MENU_ELEMENT_K, MENU_ELEMENT_V
...
menu2 {'id': '11', 'name': 'Some other name'}
menu3 {'id': '12', 'name': 'Some other other name'}
menu1 {'id': '10', 'name': 'Some name'}
is my idea totaly wrong, and how can I achieve the desired
thanks in advance
I am new to python, and I am trying to do something that I am used to do in PHP (so the promlem may be conceptional) and search quite a lot in google, but :-( no efect
I have configuration file with something like that
MENU_ELEMENTS = {
'menu1': {'id': '10', 'name': 'Some name'},
'menu2': {'id': '11', 'name': 'Some other name'},
'menu3': {'id': '12', 'name': 'Some other other name'},
}
I want to iterate them in the order I put them in, but the result always is the same without the order I put them
I use
>>> MENU_ELEMENTS = {
... 'menu2': {'id': '11', 'name': 'Some other name'},
... 'menu1': {'id': '10', 'name': 'Some name'},
... 'menu3': {'id': '12', 'name': 'Some other other name'},
... }
>>> for MENU_ELEMENT_K, MENU_ELEMENT_V in MENU_ELEMENTS.iteritems():
... print MENU_ELEMENT_K, MENU_ELEMENT_V
...
menu2 {'id': '11', 'name': 'Some other name'}
menu3 {'id': '12', 'name': 'Some other other name'}
menu1 {'id': '10', 'name': 'Some name'}
>>> MENU_ELEMENTS = {
... 'menu1': {'id': '10', 'name': 'Some name'},
... 'menu2': {'id': '11', 'name': 'Some other name'},
... 'menu3': {'id': '12', 'name': 'Some other other name'},
... }
>>> for MENU_ELEMENT_K, MENU_ELEMENT_V in MENU_ELEMENTS.iteritems():
... print MENU_ELEMENT_K, MENU_ELEMENT_V
...
menu2 {'id': '11', 'name': 'Some other name'}
menu3 {'id': '12', 'name': 'Some other other name'}
menu1 {'id': '10', 'name': 'Some name'}
is my idea totaly wrong, and how can I achieve the desired
thanks in advance