You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi folks, not sure if this is the best place to get some advice, feel free to let me know if it's not.
I'm trying to implement a Python class which has one method that uses two yield statements. My current PyCall implementation is this, but it gives me a "SyntaxError: 'yield' outside function":
using PyCall
textual = pyimport("textual")
pyimport("textual.app")
pyimport("textual.widgets")
@pydef mutable struct StopwatchApp <: textual.app.App
function compose(self)
py"""
yield textual.widgets.Header()
yield textual.widgets.Footer()
"""
end
end
The full error is this:
Traceback (most recent call last)
in <lambda>:1
/home/name/.julia/packages/PyCall/1gn3u/src/pyeval.jl:1
const Py_single_input = 256 # from Python.h
SyntaxError: 'yield' outside function
yield doesn't seem to be discussed in PyCall's docs so I'm wondering if there's an implementation for this. Please give me a shout if you can help me out :)
The text was updated successfully, but these errors were encountered:
The Python yield statement is only valid inside a Python function — that is, your py"..." block needs to include a whole function def foo(...): ... and not just a function body.
Hi folks, not sure if this is the best place to get some advice, feel free to let me know if it's not.
I'm trying to implement a Python class which has one method that uses two yield statements. My current PyCall implementation is this, but it gives me a "SyntaxError: 'yield' outside function":
The full error is this:
yield
doesn't seem to be discussed in PyCall's docs so I'm wondering if there's an implementation for this. Please give me a shout if you can help me out :)The text was updated successfully, but these errors were encountered: