Файл randomvar.py приведен ниже:
Код: Выделить всё
import numpy as np
from test_Random import call_random
def evaluate_expressions(expressions, x):
def evaluate_expression(expr, x):
return eval(expr)
# Evaluate each expression in the list
results = [evaluate_expression(expr, x) for expr in expressions]
return results
f = ['x[0]**2*y+x[1]', 'x[0]-y*x[1]']
def func(x):
return evaluate_expressions(f, x)
x = np.array([1,2])
call_random(func, x)
Код: Выделить всё
import numpy as np
yy=np.array([1,2])
def call_random(ff, x):
for i in range(2):
y = yy[i]
z = ff(x)
print(z)
использовать значение y=yy в test_Random.py каждый раз, когда я вызываю функцию call_random(func, x) в randomvar.py. Что мне следует изменить, чтобы добиться этого?
Подробнее здесь: https://stackoverflow.com/questions/787 ... other-file