doceme / py-spidev

MIT License
461 stars 203 forks source link

Suggetion on fix for generators in Python 3 #66

Closed mk2366 closed 5 years ago

mk2366 commented 6 years ago

Had the following code:

spi.writebytes(map(lambda rgb: gamma[rgb], __rgb_leds))

Which worked in Python2 but gave a IO exeption in Python3 because map returns an iterator/gererator but not a list in this case. spidev complained that max bytes was exceeded. Maybe it checked the length of the generator code.

With the suggested code it might check the length of a list (I'm not a C++ dev)

Gadgetoid commented 6 years ago

Interesting- I know I'm late to the party here, but have you built a version fix this tweak and tested it at all? It seems sane enough to me, although my Python/C binding knowledge is patchy at best.