Top "Generator" questions

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

Can I yield from an inner function?

With ES6 generators, I see code like this: var trivialGenerator = function *(array) { var i,item; for(var i=0; i < …

javascript for-loop generator yield ecmascript-6
How to get the n next values of a generator in a list (python)

I have made a generator to read a file word by word and it works nicely. def word_reader(file): …

python list generator
Class Map Generator for Fluent NHibernate

Is there a Class Map generator for Fluent NHibernate? I need something like db2hbm but I want it to …

database nhibernate fluent-nhibernate generator
How can I generate all possible IPs from a list of ip ranges in Python?

Let's say I have a text file contains a bunch of ip ranges like this: x.x.x.x-y.y.…

python ip converter generator cidr
Python 3.x: Test if generator has elements remaining

When I use a generator in a for loop, it seems to "know", when there are no more elements yielded. …

python-3.x iteration generator yield next
"yield" keyword for C++, How to Return an Iterator from my Function?

Consider the following code. std::vector<result_data> do_processing() { pqxx::result input_data = get_data_from_database(); …

c++ iterator generator coroutine yield-keyword
What does the "yield from" syntax do in asyncio and how is it different from "await"

From the perspective of someone who has written asyncio code but is looking to better understand the inner workings, what …

python async-await generator python-asyncio coroutine
yield in list comprehensions and generator expressions

The following behaviour seems rather counterintuitive to me (Python 3.4): >>> [(yield i) for i in range(3)] <generator …

python generator list-comprehension yield generator-expression
check if function is a generator

I played with generators in Nodejs v0.11.2 and I'm wondering how I can check that argument to my function is …

javascript generator yield ecmascript-6
TypeError: type object argument after * must be a sequence, not generator

Why does the following Python code raise an error TypeError: type object argument after * must be a sequence, not generator …

python generator typeerror