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.
Sur cette page du site, vous pouvez voir la vidéo en ligne Generator function in Python | Python Generator Function | Yield Keyword | Python Tutorials durée heure minute seconde en bonne qualité , qui a été Téléchargé par l'utilisateur GSS 17 janvier 2021, Partagez le lien avec vos amis et connaissances, sur youtube cette vidéo a déjà été regardée 32 fois et il a aimé 1 téléspectateurs. Bon visionnage!