1

I have created a jl file having the following content:

for i in 1:10
    println(i)
end
1+2

When I am calling that jl file in python using the following code:

import julia 
from julia.api import Julia

j = julia.Julia(compiled_modules=False)    
x = j.include("experiment.jl")

only x is being printed as 3. No integers(i) from 1-10 are not being printed. I am getting following warning:

/opt/conda/lib/python3.7/site-packages/julia/core.py:689: FutureWarning: Accessing `Julia().<name>` to obtain Julia objects is deprecated. Use `from julia import Main; Main.<name>` or `jl = Julia(); jl.eval('<name>')`.

remram
  • 4,805
  • 1
  • 29
  • 42

1 Answers1

0

Your julia program is running just fine. As you can see you get the right result from your julia script. And also your loop is running, it is just not printed to the same output stream as the one from python (that is why you don't see it). Here is a discussion how to print to the same output as python's. But I would not bother to much about it, to test if your loop actually runs try something like that:

z = 0
for i in 1:10
    z = z + i
end
z + 1
chefhose
  • 2,399
  • 1
  • 21
  • 32