In this video, you will learn Generator function in Python.
Generator in Python:
1. Generator is a function that returns an object (iterator) which we can iterate over (one value at a time).
2. A generator-function is defined like a normal function, but whenever it needs to generate a value, it does so with the yield keyword rather than return.
3. If the body of a def contains yield, the function automatically becomes a generator function.
4. Generator functions return a generator object. Generator objects are used either by calling the next method on the generator object or using the generator object in a “for in” loop.
5. "return" statement terminates a function entirely and "yield" statement pauses the function saving all its states and later continues from there on successive calls.
En esta página del sitio puede ver el video en línea Generator function in Python | Python Generator Function | Yield Keyword | Python Tutorials de Duración hora minuto segunda en buena calidad , que subió el usuario GSS 17 enero 2021, comparta el enlace con amigos y conocidos, en youtube este video ya ha sido visto 32 veces y le gustó 1 a los espectadores. Disfruta viendo!