Conversation
self.open_spi_handles looks like this: {7: 7}
calling reversed(self.open_spi_handles) throws:
Traceback (most recent call last):
File "<string>", line 1, in <module>
TypeError: 'dict' object is not reversible
| """Close all open pigpio SPI handles and stop pigpio connection | ||
| """ | ||
| for handle in reversed(self.open_spi_handles): | ||
| for handle in reversed(list(self.open_spi_handles.values())): |
There was a problem hiding this comment.
I would assume that even before Python 3.6, the reversed() built-in-function would work without turning the dict.values() (or, rather dict.keys()) iterator into a list first.
Can you please check if the following works:
for handle in reversed(self.open_spi_handles.keys()):
|
Hi, thank you for looking into this! You seem to be using a Python version before 3.6. Since Python 3.6, Dictionaries are ordered by default and they also have a https://docs.python.org/3/library/functions.html#reversed I admit that for backwards-compatibility, your fix might still be helpful. Please let me know if that works for you. |
|
Hi, Running on Raspberry Pi 3 with old Raspbian GNU/Linux 10 (buster). strangely there is no reversed() function in dict object despite being > 3.7 version. I think i will just update the machine. Up to you if you want to make it backwards compatible. |
self.open_spi_handles looks like this: {7: 7}
calling reversed(self.open_spi_handles) throws:
Traceback (most recent call last):
File "", line 1, in
TypeError: 'dict' object is not reversible