generator

Out of curiosity: How are serial numbers generated? Hints, Algorithms?

I wondering about how serial number generators and validator work. My aim would be to generate a serial number with five parts consisting of numbers and letters only. I enjoy coding as a hobby and would not call myself a professional programmer. However, I am very interested in how those interesting functions work technically to broaden...

Coroutine vs Continuation vs Generator

What is the difference between a coroutine and a continuation and a generator ? ...

Java Generator for Poisson and Uniform Distributions?

From what I understand, the standard generator is for the Normal Distribution. I have to generate random numbers according to the Normal, Uniform and Poisson Distributions, but I can't seem to find a class for the last 2. I have to generate them in the range of 0 - 999999. ...

Performance Considerations Using Multiple Layers of Generators in Python?

Are there any performance considerations for using a lot of generators chained together, as opposed to just a single generator. For example: def A(self, items): for item in self.AB(items): if object.A(): yield item def AB(self, items): for object in self.ABC(objects): if object.A() or object.B(): ...

What is "generator object" in django?

Am using Django voting package and when i use the method get_top() in the shell, it returns something like "generator object at 0x022f7AD0, i've never seen anything like this before, how do you access it and what is it? my code: v=Vote.objects.get_top(myModel, limit=10, reversed=False) print v <generator object at 0x022f7AD0> NB: I t...

Is there a replacement for Paste.Template?

I have grown tired of all the little issues with paste template, it's horrible to maintain the templates, it has no way of updating an old project and it's very hard to test. I'm wondering if someone knows of an alternative for quickstart generators as they have proven to be useful. ...

Scope of Python Recursive Generators

Hey all, I was working on a recursive generator to create the fixed integer partitions of a number and I was confused by a scoping issue. The code is similar to this snippet. def testGen(a,n): if n <= 1: print('yield', a) yield a else: for i in range(2): a[i] += n for j in testGen...

jQuery plugin generator

I have now written a few jQuery plugins which have unit tests, packing and library dependencies. This requires a base folder structure and downloads - and also the packer changes when I'm on PC or Mac (because of perl, for instance). I am thinking of writing a generator for doing these tasks similar to gem packaging and various generato...

Generating nested routes in a custom generator

I'm building a generator in rails that generates a frontend and admin controller then adds the routes to the routes file. I can get the frontend working with this: m.route_resources controller_file_name but I can't figure out how to do the same for the nested admin route (admin/controller_file_name). Anyone know how to generate these ...

How to generate permutations of a list without "reverse duplicates" in Python using generators

This is related to question How to generate all permutations of a list in Python How to generate all permutations that match following criteria: if two permutations are reverse of each other (i.e. [1,2,3,4] and [4,3,2,1]), they are considered equal and only one of them should be in final result. Example: permutations_without_duplicate...

Joining a set of ordered-integer yielding Python iterators.

Here is a seemingly simple problem: given a list of iterators that yield sequences of integers in ascending order, write a concise generator that yields only the integers that appear in every sequence. After reading a few papers last night, I decided to hack up a completely minimal full text indexer in Python, as seen here (though that ...

How do I add switches to a custom Rails generator?

Part of the generator I am writing isn't needed in all circumstances, so I need to add a switch so that I can specify whether it is run - something similar to the --skip_migration switch. How should I go about implementing this? ...

Generate from generators

I have a generator that takes a number as an argument and yields other numbers. I want to use the numbers yielded by this generator and pass them as arguments to the same generator, creating a chain of some length. For example, mygenerator(2) yields 5, 4 and 6. Apply mygenerator to each of these numbers, over and over again to the numbe...

What is the difference between an Iterator and a Generator?

What is the difference between an Iterator and a Generator? ...

Why is there no first(iterable) built-in function in Python?

I'm wondering if there's a reason that there's no first(iterable) in the Python built-in functions, somewhat similar to any(iterable) and all(iterable) (it may be tucked in a stdlib module somewhere, but I don't see it in itertools). first would perform a short-circuit generator evaluation so that unnecessary (and a potentially infinite ...

C# documentation from source?

Hello, I'm looking for a decent code documentation generator for C# that can create an html-format documentation straight from source. I don't want to use Sandcastle, because it's too tedious to use and I don't use VS for my work, though Sandcastle's output is exactly what I need. I also need the functionality of Doxygen - just save a...

Why my Python test generator simply doesn't work?

This is a sample script to test the use of yield... am I doing it wrong? It always returns '1'... #!/usr/bin/python def testGen(): for a in [1,2,3,4,5,6,7,8,9,10]: yield a w = 0 while w < 10: print testGen().next() w += 1 ...

Dynamic Graph Generator

I need to plot points of a line graph dynamically..(same like an oscilloscope in ecg).. can someone please suggest some tool that contains such a feature!!.. ...

Are Generators Threadsafe?

I have a multithreaded program where I create a generator function and then pass it to new threads. I want it to be shared/global in nature so each thread can get the next value from the generator. Is it safe to use a generator like this, or will I run into problems/conditions accessing the shared generator from multiple threads? If...

Add local variable to running generator

Lately, I tried to set local variables from outside of a running generator. The generator code also should access these variables. One trouble was, that when accessing the variables, it seamed that the interpreter was thinking it must be a global since the variable was not set in the local scope. But I don't wanted to change the global ...