How to import dependency for the functions? #3862
-
I'd like to run following Python code in Rust, but I'm not sure how to import its dependencies, e.g. random, math. def pi(n):
sum = 0.0
for i in range(n):
x, y = random.uniform(0, 1.0), random.uniform(0, 1.0)
if math.hypot(x, y) <= 1.0:
sum += 1
return sum During execution, I got the following errors; so how to import dependencies for functions.
|
Beta Was this translation helpful? Give feedback.
Answered by
adamreichold
Feb 19, 2024
Replies: 2 comments 12 replies
-
Did you try just including the relevant |
Beta Was this translation helpful? Give feedback.
12 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I did not compile or test this, but it should go something like
Note that this is in no way scoped to the current invocation of
task_fn
, it will affect the global state of the embedded Python interpreter. (But your task function will not be isolated anyway if they share that single embedded interpreter.)