def detect_java_comm(names):
 for name in names:
  try:
   mod = my_import(name)
   mod.SerialPort
   return mod
  except (ImportError, AttributeError):
   pass
 raise ImportError('No Java Communications API implementation found')

def detect_java_comm ( names ) : for name in names : try : mod = my_import ( name ) mod . SerialPort return mod except ( ImportError , AttributeError ) : pass raise ImportError ( 'No Java Communications API implementation found' )
try given list of modules and return that imports .