I'm teaching an introduction to programming with Python 3 at work, 12 weeks with a 2 hour seminar once a week and homework. Internally one of the biggest uses of Python is in hardware interaction - especially when it comes to automated testing. We communicate with embedded devices running elua, labjacks, programmable power supplies, oscilloscopes, Kvaisers and more with Python - primarily using the serial interface and abstracting the hardware with Python.
Since most of our existing code uses python2, I figured I should spend an hour looking at porting an existing Python module to python3. The python library we currently use to communicate with Labjack is an in house ctypes wrapper, but Labjack have their own Python library code so I decided to port that to Python3.
I only did the bare minimum to get the basic tutorial running but you can see forked code on github. For the most part 2to3 did everything. The modifications I had to make were all because the Labjack operates at a pretty low level. Where previously the code was converting strings into int lists with ord, I just removed that map as now it uses bytes. The only other thing that 2to3 seemed to miss was a floor division.
Since most of our existing code uses python2, I figured I should spend an hour looking at porting an existing Python module to python3. The python library we currently use to communicate with Labjack is an in house ctypes wrapper, but Labjack have their own Python library code so I decided to port that to Python3.
I only did the bare minimum to get the basic tutorial running but you can see forked code on github. For the most part 2to3 did everything. The modifications I had to make were all because the Labjack operates at a pretty low level. Where previously the code was converting strings into int lists with ord, I just removed that map as now it uses bytes. The only other thing that 2to3 seemed to miss was a floor division.