Top "Generator" questions

A generator is a generalisation of a subroutine, primarily used to simplify the writing of iterators.

What can you use Python generator functions for?

I'm starting to learn Python and I've come across generator functions, those that have a yield statement in them. I …

python generator
How to join two generators in Python?

I want to change the following code for directory, dirs, files in os.walk(directory_1): do_something() for directory, dirs, …

python generator
Resetting generator object in Python

I have a generator object returned by multiple yield. Preparation to call this generator is rather time-consuming operation. That is …

python generator yield
How do I know if a generator is empty from the start?

Is there a simple way of testing if the generator has no items, like peek, hasNext, isEmpty, something along those …

python generator
Length of generator output

Python provides a nice method for getting length of an eager iterable, len(x) that is. But I couldn't find …

python generator iterable
"'generator' object is not subscriptable" error

Why am I getting this error, from line 5 of my code, when attempting to solve Project Euler Problem 11? for x …

python generator
How to get one value at a time from a generator function in Python?

Very basic question - how to get one value from a generator in Python? So far I found I can …

python generator
how to split an iterable in constant-size chunks

Possible Duplicate: How do you split a list into evenly sized chunks in Python? I am surprised I could not …

python algorithm generator chunking
Can I use ES6's arrow function syntax with generators? (arrow notation)

ie how do I express this: function *(next) {} with arrow syntax. I've tried all the combinations I could think of, …

javascript ecmascript-6 generator arrow-functions
How do I build a numpy array from a generator?

How can I build a numpy array out of a generator object? Let me illustrate the problem: >>> …

python numpy generator