Consider using Python 3 floor division (Python 2 support can be added via from __future__ import division at top of file). nSegments = int((len(data)+5) / 6) # the +5 is since integer division takes the floor value
would become: nSegments = (len(data)+5) // 2 # +5 ensures enough space after floor division
(note that in Python 3, / would produce a float regardless of type given, where Python 2 would produce an int if dividing ints).
Consider using Python 3 floor division (Python 2 support can be added via
from __future__ import division
at top of file).nSegments = int((len(data)+5) / 6) # the +5 is since integer division takes the floor value
would become:nSegments = (len(data)+5) // 2 # +5 ensures enough space after floor division
(note that in Python 3,/
would produce a float regardless of type given, where Python 2 would produce an int if dividing ints).