AI engineering glossary · Python advanced
What is yield?
yield: A keyword that turns a function into a generator. When reached, it hands a value back to the caller and freezes the function, so a later request resumes right after it with all variables intact.
yield: an example
def read_lines(f): for line in f: yield line.strip() returns cleaned lines one by one from a huge file.
Related terms
More Python advanced terms
Where you learn it
yield is part of the AI Engineering Program, which teaches it with notes, a hands-on lab and an exam. The first lesson is free.