def bytes2int(bytes):
 if (not ((type(bytes) is types.ListType) or (type(bytes) is types.StringType))):
  raise TypeError('You must pass a string or a list')
 integer = 0
 for byte in bytes:
  integer *= 256
  if (type(byte) is types.StringType):
   byte = ord(byte)
  integer += byte
 return integer

def bytes2int ( bytes ) : if ( not ( ( type ( bytes ) is types . ListType ) or ( type ( bytes ) is types . StringType ) ) ) : raise TypeError ( 'You must pass a string or a list' ) integer = 0 for byte in bytes : integer *= 256 if ( type ( byte ) is types . StringType ) : byte = ord ( byte ) integer += byte return integer
converts a list of bytes or a string to an integer .