From lawsie at gmail.com Tue Dec 20 04:38:52 2016 From: lawsie at gmail.com (Laura Sach) Date: Tue, 20 Dec 2016 09:38:52 +0000 Subject: [Pythonedu-wg] Bit shift problem Message-ID: Hi all, I'm working on a resource which reads weather data, and I'm using this code to read data from a BMP180 barometric pressure sensor. https://github.com/lawsie/barometric-sensor The code in the file bmpBackend_py3.py (and the Adafruit I2c/bmp085 files) was originally in Python 2 and I converted it using 2to3. However this has resulted in the bit shifts not working any more in the readPressure() method. This code works in Python 2 but I need the resource to be in Python 3. I've included the Python 2 bmpBackend file too for comparison in case the tool has changed something odd. I predict the problem is to do with the redefinition of the / operator from 2 to 3, but I don't know enough about bit shifting to figure out what to do to resolve it. Would anyone be able to help me to get this working? :) Many thanks, Laura -------------- next part -------------- An HTML attachment was scrubbed... URL: From carrieanne at raspberrypi.org Tue Dec 20 04:51:21 2016 From: carrieanne at raspberrypi.org (Carrie Anne Philbin) Date: Tue, 20 Dec 2016 09:51:21 +0000 Subject: [Pythonedu-wg] Bit shift problem In-Reply-To: References: Message-ID: Just to add to what Laura has said. This resource is part of a global weather experiment. We have 1000 schools around the world taking part and we want them to be able to program them with Python as well as with Java. Helping with the conversion from 2 to 3 would impact a lot of young people! Thanks, Carrie Anne On Tue, Dec 20, 2016 at 9:38 AM, Laura Sach wrote: > Hi all, > > I'm working on a resource which reads weather data, and I'm using this > code to read data from a BMP180 barometric pressure sensor. > > https://github.com/lawsie/barometric-sensor > > > The code in the file bmpBackend_py3.py (and the Adafruit I2c/bmp085 files) > was originally in Python 2 and I converted it using 2to3. However this has > resulted in the bit shifts not working any more in the readPressure() > method. > > This code works in Python 2 but I need the resource to be in Python 3. > I've included the Python 2 bmpBackend file too for comparison in case the > tool has changed something odd. > > I predict the problem is to do with the redefinition of the / operator > from 2 to 3, but I don't know enough about bit shifting to figure out what > to do to resolve it. > > Would anyone be able to help me to get this working? :) > > Many thanks, > Laura > > > > > > _______________________________________________ > Pythonedu-wg mailing list > Pythonedu-wg at python.org > https://mail.python.org/mailman/listinfo/pythonedu-wg > > -- Director of Education Raspberry Pi Foundation UK Charity No. 1129409 www.raspberrypi.org | www.codeclub.org.uk @ | in | *?* -------------- next part -------------- An HTML attachment was scrubbed... URL: From mail at timgolden.me.uk Tue Dec 20 05:17:21 2016 From: mail at timgolden.me.uk (Tim Golden) Date: Tue, 20 Dec 2016 10:17:21 +0000 Subject: [Pythonedu-wg] Bit shift problem In-Reply-To: References: Message-ID: On 20/12/2016 09:38, Laura Sach wrote: > Hi all, > > I'm working on a resource which reads weather data, and I'm using this > code to read data from a BMP180 barometric pressure sensor. > > https://github.com/lawsie/barometric-sensor Laura, I may be missing something, but it looks to me as though Adafruit have already done this for the modules you're using. The repo you point to at the head of the backend file: https://github.com/adafruit/Adafruit-Raspberry-Pi-Python-Code/ describes how they've broken the code out into smaller repos and made them work with Py2/3. Certainly https://github.com/adafruit/Adafruit_Python_BMP and https://github.com/adafruit/Adafruit_Python_GPIO/blob/master/Adafruit_GPIO/I2C.py seem, by inspection, to be 2/3 compatible. I'm happy to help, but is it possible that you're re-inventing the wheel here? Or have I missed something? TJG From lawsie at gmail.com Tue Dec 20 05:27:52 2016 From: lawsie at gmail.com (Laura Sach) Date: Tue, 20 Dec 2016 10:27:52 +0000 Subject: [Pythonedu-wg] Bit shift problem In-Reply-To: References: Message-ID: THANK YOU Tim! Sometimes you can't see the wood for the trees - I inherited that old code and it didn't occur to me to see if someone had since made a Python 3 Adafruit library. That works perfectly and is super easy to install and use. The Barometric Pressure sensor *shall* go to the ball! :) Laura On Tue, Dec 20, 2016 at 10:17 AM, Tim Golden wrote: > On 20/12/2016 09:38, Laura Sach wrote: > >> Hi all, >> >> I'm working on a resource which reads weather data, and I'm using this >> code to read data from a BMP180 barometric pressure sensor. >> >> https://github.com/lawsie/barometric-sensor >> > > Laura, > > I may be missing something, but it looks to me as though Adafruit have > already done this for the modules you're using. The repo you point to at > the head of the backend file: > > https://github.com/adafruit/Adafruit-Raspberry-Pi-Python-Code/ > > describes how they've broken the code out into smaller repos and made them > work with Py2/3. > > Certainly > > https://github.com/adafruit/Adafruit_Python_BMP > > and > > > https://github.com/adafruit/Adafruit_Python_GPIO/blob/master > /Adafruit_GPIO/I2C.py > > seem, by inspection, to be 2/3 compatible. > > I'm happy to help, but is it possible that you're re-inventing the wheel > here? Or have I missed something? > > > TJG > -------------- next part -------------- An HTML attachment was scrubbed... URL: From ccosse at gmail.com Tue Dec 20 09:41:58 2016 From: ccosse at gmail.com (=?UTF-8?Q?Charles_Coss=C3=A9?=) Date: Tue, 20 Dec 2016 07:41:58 -0700 Subject: [Pythonedu-wg] Bit shift problem In-Reply-To: References: Message-ID: bash-3.2$ python Python 3.5.2 |Anaconda custom (x86_64)| (default, Jul 2 2016, 17:52:12) [GCC 4.2.1 Compatible Apple LLVM 4.2 (clang-425.0.28)] on darwin Type "help", "copyright", "credits" or "license" for more information. >>> 10>>1 5 >>> 10.>>1 Traceback (most recent call last): File "", line 1, in TypeError: unsupported operand type(s) for >>: 'float' and 'int' >>> Hi, don't know how I came to receive this email, and didn't see that you had it solved until after playing with it ... but the problem is shifting bits on a float ... needs to be an int. -C On Tue, Dec 20, 2016 at 3:27 AM, Laura Sach wrote: > THANK YOU Tim! Sometimes you can't see the wood for the trees - I > inherited that old code and it didn't occur to me to see if someone had > since made a Python 3 Adafruit library. That works perfectly and is super > easy to install and use. > > The Barometric Pressure sensor *shall* go to the ball! :) > > Laura > > On Tue, Dec 20, 2016 at 10:17 AM, Tim Golden wrote: > >> On 20/12/2016 09:38, Laura Sach wrote: >> >>> Hi all, >>> >>> I'm working on a resource which reads weather data, and I'm using this >>> code to read data from a BMP180 barometric pressure sensor. >>> >>> https://github.com/lawsie/barometric-sensor >>> >> >> Laura, >> >> I may be missing something, but it looks to me as though Adafruit have >> already done this for the modules you're using. The repo you point to at >> the head of the backend file: >> >> https://github.com/adafruit/Adafruit-Raspberry-Pi-Python-Code/ >> >> describes how they've broken the code out into smaller repos and made >> them work with Py2/3. >> >> Certainly >> >> https://github.com/adafruit/Adafruit_Python_BMP >> >> and >> >> >> https://github.com/adafruit/Adafruit_Python_GPIO/blob/master >> /Adafruit_GPIO/I2C.py >> >> seem, by inspection, to be 2/3 compatible. >> >> I'm happy to help, but is it possible that you're re-inventing the wheel >> here? Or have I missed something? >> >> >> TJG >> > > > _______________________________________________ > Pythonedu-wg mailing list > Pythonedu-wg at python.org > https://mail.python.org/mailman/listinfo/pythonedu-wg > > -- Linkedin | E-Learning -------------- next part -------------- An HTML attachment was scrubbed... URL: From chalmer.lowe at gmail.com Sat Dec 31 07:54:42 2016 From: chalmer.lowe at gmail.com (Chalmer Lowe) Date: Sat, 31 Dec 2016 12:54:42 +0000 Subject: [Pythonedu-wg] Submit talks for Python Education Summit: Jan 3rd deadline Message-ID: Do you teach? Do you Python? The deadline to submit your talk proposal to speak at the Python Education Summit is on January 3rd. More details on the submission process here: http://bit.ly/2hxv4HO We can't wait to hear what works (and what doesn't) in teaching Python, whether you teach in a classroom or teach through the written word. Join us for an awesome day full of Python AND Education with educators from around the world @ the annual Pycon Conference. Respectfully, Chalmer | Jessica | Meenal | Ria -- Chalmer Lowe, MS PyHawaii Dark Art of Coding Booz Allen Hamilton -------------- next part -------------- An HTML attachment was scrubbed... URL: