Looping OrderedDict in reverse order #11881
-
|
I have an OrderedList of items and I would like to loop the items in reverse order like: This produces following running on micropython (1.20.0, linux build): The code works fine using python 3.9.2 /3.5.2/, so the expected output should be: Looking at python's 3.5.2 docs. The docs here: https://docs.python.org/3.5/library/collections.html#collections.OrderedDict say that the object must have either Is this a bug or am I missing something? Thanks |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 1 reply
-
|
According to docs https://docs.micropython.org/en/latest/genrst/builtin_types.html?highlight=dict_view#dict which propose a workaround to explicitly convert keys to a set before using set operations. I converted them to a list which can be reverted using: |
Beta Was this translation helpful? Give feedback.
-
|
Micropython is developed for Microcontrollers and must be very memory efficient. The reversed method is not implemented for Possible inefficient solution: It's simpler to use a |
Beta Was this translation helpful? Give feedback.
-
|
Thanks @sosi-deadeye . I need a dictionary, so for now I will just use this, I will try to implement my code using lists when optimizing the app. Also to note is that micropython's |
Beta Was this translation helpful? Give feedback.
Micropython is developed for Microcontrollers and must be very memory efficient. The reversed method is not implemented for
OrderedDictnor fordict.Possible inefficient solution:
It's simpler to use a
listfor task…