About 16,100,000 results
Open links in new tab
  1. Understanding generators in Python - Stack Overflow

    Are Python generators basically Turing machines in terms of how they function? you can also add that the function becomes a generator regardless of the reachability of the yield construct So …

  2. Difference between Python's Generators and Iterators

    What is the difference between iterators and generators? Some examples for when you would use each case would be helpful.

  3. How can I type hint a generator in Python 3? [duplicate]

    The Iterator, Generator, and Iterable are slightly different in details and carry different type of information, so understanding the difference might help choosing the correct one for your …

  4. What does the "yield" keyword do in Python? - Stack Overflow

    Oct 24, 2008 · Yield in Python used to create a generator function. Generator function behaves like an iterator, which can be used in loop to retrieve items one at a time. When a generator …

  5. python - How to loop through a generator - Stack Overflow

    How can one loop through a generator? I thought about this way: gen = function_that_returns_a_generator(param1, param2) if gen: # in case the generator is null …

  6. What is the purpose of the "send" function on Python generators?

    generator.send(value) Resumes the execution and “sends” a value into the generator function. The value argument becomes the result of the current yield expression. The send() method …

  7. How to join two generators (or other iterables) in Python?

    How to join two generators (or other iterables) in Python? Asked 15 years, 5 months ago Modified 2 years, 2 months ago Viewed 165k times

  8. python - How to take the first N items from a generator or list ...

    With itertools you will obtain another generator object so in most of the cases you will need another step the take the first n elements. There are at least two simpler solutions (a little bit …

  9. python - What can you use generator functions for? - Stack Overflow

    The generator pauses at each yield until the next value is requested. If the generator is wrapping I/O, the OS might be proactively caching data from the file on the assumption it will be …

  10. GeneratorExit in Python generator - Stack Overflow

    Jun 16, 2015 · To prevent this, when a generator is garbage-collected, Python calls its close method, which raises a GeneratorExit exception at the point from which the generator last …