def pyval(expr: str, ns: Namespace) -> None: """ Évalue une expression. Retour (sérialisé) via pipe """ try: evaluation = safe_eval(expr) except BaseException as ex: evaluation = ex ns.evaluation = evaluation
def pyval(expr: str, queue: Queue) -> None: """ Évalue une expression. Retour (sérialisé) via pipe """ try: evaluation = safe_eval(expr) except BaseException as ex: evaluation = ex queue.put(evaluation)
def pyval(expr: str, retour: list) -> None: """ Évalue une expression. Reour via via argument """ try: assert retour[0] == 99 retour[0] = safe_eval(expr) print(expr, '=', retour[0]) except BaseException as ex: exexit(ex)
def pyval(expr: str, pipe: Connection) -> None: """ Évalue une expression. Retour (sérialisé) via pipe """ try: evaluation = safe_eval(expr) except BaseException as ex: evaluation = ex pipe.send(evaluation) pipe.close()
def pyval(expr: str) -> None: """ Évalue une expression. Reour via varaible globale """ global EVALUATION try: EVALUATION = safe_eval(expr) print(expr, '=', EVALUATION) except BaseException as ex: exexit(ex)
def pyval(expr: str, retour: Value) -> None: """ Évalue une expression. Reour via via Multiprocessing.Value (shared memory) Type supporté: c_double = python float """ try: assert retour.value == 99 retour.value = float(safe_eval(expr)) print(expr, '=', retour.value) except BaseException as ex: exexit(ex)
def pyval(expr: str, retour: mp.Array) -> None: """ Évalue une expression. Reour via via Multiprocessing.Value (shared memory) Type supporté: c_double = python float """ try: evaluation = safe_eval(expr) except BaseException as ex: evaluation = ex serialisation: bytes = pickle.dumps(evaluation) retour[:len(serialisation)] = serialisation
def pyval(expr: str, filename: str) -> None: """ Évalue une expression. Reour via sérialisation dans un fichieer. Même l'exeption est retournée """ try: evaluation = safe_eval(expr) print(expr, '=', evaluation) except BaseException as ex: evaluation = ex with open(filename, 'w+b') as f: pickle.dump(evaluation, f)
def pyval(expr: str, filename: str) -> None: """ Évalue une expression. Reour via via Multiprocessing.Value (shared memory) Type supporté: c_double = python float """ try: evaluation = safe_eval(expr) print(expr, '=', evaluation) with open(filename, 'w+b') as f: pickle.dump(evaluation, f) except BaseException as ex: exexit(ex)