def safe_py_code(code):
 bads = ('import', ';', 'subprocess', 'eval', 'open', 'file', 'exec', 'input')
 for bad in bads:
  if code.count(bad):
   return False
 return True

def safe_py_code ( code ) : bads = ( 'import' , ';' , 'subprocess' , 'eval' , 'open' , 'file' , 'exec' , 'input' ) for bad in bads : if code . count ( bad ) : return False return True
check a string to see if it has any potentially unsafe routines which could be executed via python .