Dinesh Beniwal
What are the generators in python?
By Dinesh Beniwal in Python on Jun 24 2019
  • Amit Prabhu
    Jun, 2019 24

    generators are like function but it not returning value. but it generates using yield keyword example : def simpleGenerator(): yield 1 yield 2 yield 3 for value in simpleGenerator(): print(value) then output : 1 2 3

    • 3
  • Rohit Gupta
    Nov, 2021 8

    Hi,

    A decorator is a Python design pattern that allows a user to add additional functionality to an existing object without changing its structure. Decorators are often summoned prior to the specification of the function to be decorated. These are used to alter the function’s behavior. Decorators allow you to wrap another function in order to extend the functionality of the wrapped function without permanently changing it.

    You can learn more, here.

    Thanks

    • 0
  • Arvind Singh
    Jul, 2019 18

    generator is like a normal function, but they do not return a value, they yield it. If the body of a def contains yield, the function automatically becomes a generator function.

    • 0


Most Popular Job Functions


MOST LIKED QUESTIONS