Questions tagged [yield]
yield is (1) a keyword that facilitates creation of generator functions, (2) a Ruby statement to transfer control from one coroutine to another, (3) a Java statement used to yield a value from a switch expression.
yield
1,741
questions
0
votes
3
answers
156
views
Issues in Streaming response from flask-smorest
I'm encountering issues in streaming response in flask-smorest. I'm following the guidance here - https://flask.palletsprojects.com/en/2.3.x/patterns/streaming/ for streaming responses from my flask-...
0
votes
2
answers
72
views
pytest fixture _cleanup_data not printing expected message (Don't run cleanup section)
I'm having an issue with a pytest fixture in my Python code. The fixture is supposed to print a message after cleaning up test data, but the message is not being printed. I've checked the code and the ...
0
votes
1
answer
58
views
Python, Tkinter: Apply delay to function inside generator
I am making an application in python tkinter to visualize algorithms. I want to apply a delay (window.after()) to the function partition() called inside quick_sort. The window.after() seems to only ...
-1
votes
1
answer
40
views
Surprising result with a conditional `yield` [duplicate]
I have the following Python code using yield:
def foo(arg):
if arg:
yield -1
else:
return range(5)
Specifically, the foo() method shall iterate over a single value (-1) if its ...
0
votes
0
answers
10
views
My decorator does not work when I run the program
I am programming a machine that gives shifts for meat, fish and fruit in a supermarket. I have 2 modules, numbers.py and main. In numeros.py is the code of a function decorator and three generators. ...
0
votes
0
answers
34
views
html progress bar for python image processing code
I'm rather new, inexperienced, and need some help. I want to implement a progress bar for my image processing python code to return to an HTML page, but I've been having issues getting the progress ...
0
votes
2
answers
51
views
Python SciPy differential_evolution yield progress
I am using SciPy differential_evolution to solve an optimization problem. I have a web application that I want to show the progress in. What would be a good technique for giving intermediate feedback ...
1
vote
3
answers
105
views
Redefine input function in Python to yield a value from a predetermined list of values each time it's called
Is there a clean "Pythonic" way to write an input-replacement function in Python that will yield a value from a predetermined list of input values each time it's called?
raw_data = ['8', '2',...
0
votes
0
answers
65
views
Why does delay() suspend a coroutine but yield() doesn't, inside Kotlin's runTest{} function?
The simplified test below has been converted from using runBlocking to runTest to make it work with Kotlin Multiplatform. However, runTest causes it to fail. Debugging shows that the delay in job1 ...
0
votes
1
answer
200
views
Is it possible to yield one compressed file at a time in FastAPI into a single archive using StreamingResponse?
I have code that creates a zip archive of files and streams it. The problem is, for large requests, this means there can be minutes of processing time before the data is streamed, making cancelling ...
0
votes
0
answers
40
views
Laravel9 response()->stream() empty result with fwrite()
I need to export huge amount of data as csv string.
So I tried to use fopen('php://stdout', w) with fwrite($file, $data).
But Laravel response()->stream() do not return anything nor error.
I have ...
-1
votes
1
answer
86
views
Batch from yield don't start up concurrently
I'm currently trying to implement a file searcher that yields found files in batches so it can get processed concurrently. But my problem arrives when it yields and I pass it to a task. It never ...
1
vote
1
answer
96
views
Python - reverse nested dictionaries dict in dict
I am trying to reverse dictionary nesting such that dict2 in dict1 becomes dict1 in dict2. For this, I followed the method from the link:
Pythonic Way to reverse nested dictionaries
This dictionary ...
0
votes
0
answers
34
views
Discord bot, extra input for functions and showing the input message without "returning" me from the function
I need the discord bot to take extra input for functions or rather find a way so while I use the bot in python, not only return something without exiting the function made for the messages but also ...
1
vote
1
answer
95
views
Is it pythonic to put return after yield? [closed]
Consider the following code:
def some_gen():
if some_condition:
yield "Condition"
return
for ....:
yield some_value
'return' after 'yield' hurts my eyes, is ...