JuliaPy / JuliaPy/PyCall.jl

Howto - Python yield statement

Aperta
#1,081 1 commento 0 reazioni 0 assegnatari Vedi su GitHub
Lingua principale
Julia
Stelle
1.5k
Fork
186
Metriche di merge delle PR
Nessuna PR unita negli ultimi 30g

Descrizione

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 :)

Guida per i contributori

Nessuna guida per i contributori indicizzata per questo repository

Direzione di ricerca

Begin with the @pydef method and the py"""...""" block in the report, then inspect the pyeval.jl location shown in the traceback. Determine whether this yield example can be supported or documented, and make the behavior or documented usage clear.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Valutazione

Stack tecnologico
julia, python
Ambito
documentation
Tipo di issue
Documentazione
Difficoltà
4/5
Tempo stimato
3-5 giorni
Stato di attività
Ferma
Chiarezza
Da chiarire
Idoneità per principianti
25/100

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.