adafruit / Adafruit-Raspberry-Pi-Python-Code

Adafruit library code for Raspberry Pi
1.43k stars 686 forks source link

Fixes Github Issue 140 in Adafruit's repository #148

Closed buckbaskin closed 5 years ago

buckbaskin commented 8 years ago

This change was made in response to a Github Issue #140 and a question on an Adafruit forum: https://forums.adafruit.com/viewtopic.php?f=47&t=85731&p=432043&sid=584c7d7c80739693b81e5e0112c7c104#p432043)

The error comes from this line: https://github.com/adafruit/Adafruit-Raspberry-Pi-Python-Code/blob/master/Adafruit_LEDpixels/Adafruit_LEDpixels.py#L73

The error was caused by Python3 using floating point division when Python2 would use integer division. The change uses a // instead of / which forces both languages to use integer division.

In Python2, 10 / 3 gives 3 In Python3, 10 / 3 gives 3.333333

After the change:

In Python2, 10 // 3 gives 3 In Python3, 10 // 3 gives 3

The output of the code is now the same, regardless of Python 2 vs. 3 as tested on my interpreters (2.7.6 and 3.5.1).

ladyada commented 5 years ago

This library has been deprecated in favor of our python3 Blinka library. We have replaced all of the libraries that use this repo with CircuitPython libraries that are Python3 compatible, and support a wide variety of single board/linux computers!

Visit https://circuitpython.org/blinka for more information

CircuitPython has support for almost 200 different drivers, and a as well as FT232H support for Mac/Win/Linux!