def DecodeVarLengthNumber(byte_str):
 value = 0
 num_bytes = 0
 for shift in xrange(0, 64, 7):
  (byte,) = struct.unpack('>B', byte_str[num_bytes:(num_bytes + 1)])
  num_bytes += 1
  if (byte & 128):
   value |= ((byte & 127) << shift)
  else:
   value |= (byte << shift)
   return (value, num_bytes)
 raise TypeError('string not decodable as variable length number')

def DecodeVarLengthNumber ( byte_str ) : value = 0 num_bytes = 0 for shift in xrange ( 0 , 64 , 7 ) : ( byte , ) = struct . unpack ( '>B' , byte_str [ num_bytes : ( num_bytes + 1 ) ] ) num_bytes += 1 if ( byte & 128 ) : value |= ( ( byte & 127 ) << shift ) else : value |= ( byte << shift ) return ( value , num_bytes ) raise TypeError ( 'string not decodable as variable length number' )
interprets a raw byte string as a variable length encoded number and decodes .