How to load and call functions defined in a standalone Python script?



Can PyCall be used to load definitions from a small Python script into Julia? For example, how can I call foo() defined in the Python script below in Julia?

a = 1
b = 2
def foo():
    print("Hello world!")
    return a + b


Just do what you would have done in python

julia> using PyCall

julia> push!(pyimport("sys")["path"], pwd());

julia> pyimport("a")[:foo]()
Hello world!


Thank you @yuyichao, I will give the solution a try. :slight_smile: