Can't I use pyeval with multiple statements?
#551
Replies: 2 comments 5 replies
-
|
Correct, So you need to use @pyexec """
x = 1+1
y = 1+1
""" => y |
Beta Was this translation helpful? Give feedback.
-
|
From the docstring and some basic tests, it looks like running code in If running an interactive session, for example, I would expect that variables are propagated from one cell to the next, without having to append |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
I was looking into supporting python cells in QuartoNotebookRunner using PythonCall. A python cell in the context of a Julia notebook would mean that PythonCall would handle executing the python code in the cell and then return the last object converted to Julia.
I've found
pyevalbut it seems not to support multiple statements:I can run such code blocks with
pyexecbut this doesn't return the last result. One hacky workaround would be to split the code I get into parts where only the last statement ispyevaled, but then I'd have to analyze the code which seems very error prone. So I'm hoping there's maybe a different way to usepyevalthat I haven't yet found?Beta Was this translation helpful? Give feedback.
All reactions