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

Опубликовано: 17 Январь 2021
на канале: 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.


На этой странице сайта вы можете посмотреть видео онлайн Generator function in Python | Python Generator Function | Yield Keyword | Python Tutorials длительностью часов минут секунд в хорошем качестве, которое загрузил пользователь GSS 17 Январь 2021, поделитесь ссылкой с друзьями и знакомыми, на youtube это видео уже посмотрели 32 раз и оно понравилось 1 зрителям. Приятного просмотра!