def detect_format(stream):
 for fmt in formats.available:
  try:
   if fmt.detect(stream):
    return fmt.title
  except AttributeError:
   pass

def detect_format ( stream ) : for fmt in formats . available : try : if fmt . detect ( stream ) : return fmt . title except AttributeError : pass
return format name of given stream .