Top "Generator" questions

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

What does the "yield" keyword do?

What is the use of the yield keyword in Python, and what does it do? For example, I'm trying to …

python iterator generator yield coroutine
Random color generator

Given this function, I want to replace the color with a random color generator. document.overlay = GPolyline.fromEncoded({ color: "#0000FF", …

javascript random colors generator
How to take the first N items from a generator or list?

With linq I would var top5 = array.Take(5); How to do this with Python?

python list generator
Lazy Method for Reading Big File in Python?

I have a very big file 4GB and when I try to read it my computer hangs. So I want …

python file-io generator
Ruby on Rails generates model field:type - what are the options for field:type?

I'm trying to generate a new model and forget the syntax for referencing another model's ID. I'd look it up …

ruby-on-rails generator rails-activerecord
Any tools to generate an XSD schema from an XML instance document?

I am looking for a tool which will take an XML instance document and output a corresponding XSD schema. I …

xml xsd schema generator
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.

python iterator generator
How to pick just one item from a generator?

I have a generator function like the following: def myfunct(): ... yield result The usual way to call this function would …

python iterator generator python-2.x
How can I generate a random number in a certain range?

How can I create an app that generates a random number in Android using Eclipse and then show the result …

android random numbers range generator
Generator Expressions vs. List Comprehension

When should you use generator expressions and when should you use list comprehensions in Python? # Generator expression (x*2 for x …

python list-comprehension generator