Howto - Python yield statement
- Dominant language
- Julia
- Stars
- 1.5k
- Forks
- 186
- PR merge metrics
- No merged PRs in 30d
Description
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 :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 :)
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.