code: def bin_to_int(string):
      
      if isinstance(string, str):
          return struct.unpack("b", string)[0]
      else:
          return struct.unpack("b", bytes([string]))[0]
docs: Convert a one element byte string to signed int for python 2 support.