Replies: 2 comments
-
|
Not sure if this is a good way to do it, but it works for me now: const mypy = PythonCall.pynew()
function __init__()
sys = PythonCall.pyimport("sys")
sys.path.append(pwd())
PythonCall.pycopy!(mypy, PythonCall.pyimport("src.pythonscripts.mypy")) # load the mypy.py in that folder
end
function test()
mypy.test()
end |
Beta Was this translation helpful? Give feedback.
0 replies
-
|
Something like this function __init__()
pyexec(read(String, "/path/to/mypy.py"), @__MODULE__)
end
function test()
@pyeval("test")()
endThis differs from your solution in that the file is not loaded as a module. Instead the statements are just executed in some global context specific to your module (hence Or you can access the global context const mypy = Ref{Py}()
function __init__()
pyexec(read(String, "/path/to/mypy.py"), @__MODULE__)
mypy[] = @pyeval("globals()")
end
function test()
mypy["test"]()
end |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
I have a small python script (.py) which defines a few functions that I want to wrap in Julia.
Up to now I was using PyCall with
@pyinclude.How can I achieve this (importing/including a .py file) with PythonCall?
Thank you for your help :)
Beta Was this translation helpful? Give feedback.
All reactions