Python - Julia variables transfering

Viewed 122

Let's say I have a jupyter notebook with both python and julia. In julia i have a variable

var_julia = 10

and in python I have

var_python = 20

What I would like to do is to efficiently (without any JSONs nor CSVs) transfer these 2 variables between, so I can print var_julia in python and var_python in julia. How should I do that?

2 Answers

Basically using the forementioned PyCall PyJulia you can do:

var_python = 10

%%julia
py"var_python"

and for the other way round:

var_julia = 20

new_var = %julia var_julia
print(new_var)
Related