Generator function in Python | Python Generator Function | Yield Keyword | Python Tutorials

Pubblicato il: 17 gennaio 2021
sul canale di: GSS
32
1

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.


In questa pagina del sito puoi guardare il video online Generator function in Python | Python Generator Function | Yield Keyword | Python Tutorials della durata di ore minuti seconda in buona qualità , che l'utente ha caricato GSS 17 gennaio 2021, condividi il link con amici e conoscenti, su youtube questo video è già stato visto 32 volte e gli è piaciuto 1 spettatori. Buona visione!