+ 3

What is generator in python?

I don't understand generator and what is generator in other languages like Java and c++?

24th Jan 2017, 11:11 PM
Shahenda Mohamed Rashad
Shahenda Mohamed Rashad - avatar
3 Respostas
+ 12
Python generator : Generators functions allow you to declare a function that behaves like an iterator, i.e. it can be used in a for loop.
25th Jan 2017, 7:09 AM
Hassan Amr
Hassan Amr - avatar
+ 2
I read this definition but it's not clear for me. Are there any other explanation?
25th Jan 2017, 7:00 PM
Shahenda Mohamed Rashad
Shahenda Mohamed Rashad - avatar
+ 2
generator basically allows you to return a function's output infinite times using for and yield instead of return word where you just exit the function by destroying all the temporary values created in between
20th Mar 2017, 1:43 PM
Akash Pradhan
Akash Pradhan - avatar