-
|
I'm trying to do something like Is this possible and if so how? |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 2 replies
-
|
Alternatively Btw there is no distinction between single- and multi-line code (unlike PyCall's |
Beta Was this translation helpful? Give feedback.
-
|
Got it, thanks. May I suggest making an easier-to-read version of this? Seems like putting a bunch of imports at the top of a script or module is pretty typical. What about this?: @pyexec @__MODULE__ """
import numpy as np
""" |
Beta Was this translation helpful? Give feedback.
@pyexecalways runs in a local scope. I think puttingglobal npat the top of the first call does what you want.Alternatively
pyexec("import numpy as np", @__module__)works in global scope unless you provide a local scope in the 3rd arg.Btw there is no distinction between single- and multi-line code (unlike PyCall's
py"..."macro). You probably want@pyevalfor your second call.