def strip_bom(data):
 for bom in (codecs.BOM_UTF32_BE, codecs.BOM_UTF32_LE, codecs.BOM_UTF16_BE, codecs.BOM_UTF16_LE, codecs.BOM_UTF8):
  if data.startswith(bom):
   data = data[len(bom):]
   break
 return data

def strip_bom ( data ) : for bom in ( codecs . BOM_UTF32_BE , codecs . BOM_UTF32_LE , codecs . BOM_UTF16_BE , codecs . BOM_UTF16_LE , codecs . BOM_UTF8 ) : if data . startswith ( bom ) : data = data [ len ( bom ) : ] break return data
strip the bom from byte string data .