The tag has no wiki summary.

learn more… | top users | synonyms

0
votes
1answer
38 views

Filtering a long list of files through a set of ignore patterns using iterators

I have a backup job that walks across a huge directory with potentially millions of files. Python's os.walk() works just fine. Now, I have implemented a feature to ignore files based in a black list ...
0
votes
1answer
50 views

Random string generator [closed]

I have made a simple number generator, and I have a question: is it possible for the generator to eject "red", "blue", "green", " yellow" and "white" instead of the numbers 1-5? namespace ...
2
votes
1answer
41 views

Subscriptable/Indexable generator

I'm not a Python developper, but I enjoy programming with it, and for a project I wanted to have generators that I can easily index. Using python's slice model is obviously the way to go, and here's ...
1
vote
1answer
87 views

DFS algorithm with generators

Background: I was working on a project were I needed to write some rules for text-processing. After working on this project for a couple of days and implementing some rules, I realized I needed to ...
3
votes
3answers
518 views

Random String generator in C

I created this small function just to practice C code. It's a simple random string generator. #include <string.h> #include <time.h> char *randstring(int length) { static int ...
1
vote
2answers
140 views

Generator to Tuple to List?

I have a method that takes a generator, converts it into a tuple to sort it, then into a list. It works perfectly, but being as I am fairly new to the Python world, I keep asking myself if it is worth ...
3
votes
0answers
173 views

A c++ PEG parser generator

Last Weekend I wrote a c++ PEG packrat parser generator and would love to get some feedback on the code and/or syntax. I currently use the << operator for defining grammar expressions and ...
2
votes
1answer
160 views

Efficiency of Recursive Checkers Legal Move Generator

I'm implementing a checkers engine for a scientific experiment. I found out through profiling that this is one of the functions that takes up a lot of time. I'm not looking for an in-depth analysis, ...
0
votes
0answers
196 views

Array Creation Inspired by Python's List Comprehension

I challenged myself to develop something functionally similar to Python's list-comprehension. Below is what I came up with. Obviously, Javascript doesn't have the elegant syntax, so ll = [x for x in ...
2
votes
0answers
187 views

Is there better way to read from a file and connect all data in one big data than to use generators?

Is there better way to read from a file and connect all data in one big data than to use generators? At the moment, I do the following: use generators to read data from files. use numpy to pack all ...
1
vote
1answer
140 views

Discrete random variable generator

There is my SSCCE to generate a value of discrete random variable. values is set of value the RV can take and procents is equivalent to discrete pdf. Can you anticipate any issue with this snippet? ...
3
votes
0answers
206 views

Iterator and Generator version of python range function

I have created iterator and generator version of python range function Here is Generator version: def irange(*args): if len(args) > 3: raise TypeError('irange() expected at most 3 ...
1
vote
1answer
194 views

Objective-C CF Random Name Generator

Based on a python name generator grammar I found here I've decided to write my own in objective-C. The idea is I can load the grammar from a plist file and generate random names from it. I'm looking ...
2
votes
3answers
156 views

Need advice regarding Style and Flow in C++ (Simple randomization program)

I come here humbly asking for advice from those with more experience than I. I believe this is a novice question but I hope it is useful to others. I'm a few months into learning C++ programming and I ...
3
votes
2answers
232 views

Text parser implemented as a generator

I often need to parse tab-separated text (usually from a huge file) into records. I wrote a generator to do that for me; is there anything that could be improved in it, in terms of performance, ...
1
vote
2answers
132 views

Can this python generator be made more efficient?

I'm trying to get a better grasp on generators in python because I don't use them enough (I think generators are cool). To do so I wrote a generator for prime numbers: def primes(): x = 2 ...
1
vote
2answers
315 views

Random Topic Generator

I've written a python module that randomly generates a list of ideas that can be used as the premises for furthur research. For instance, it would be useful in situations where a new thesis topic is ...
2
votes
2answers
236 views

Python generator to produce lattice points on an n-simplex.

Looking for a code review, and hopefully to learn something if someone has a nicer solution. Here's what I wrote: from __future__ import division, print_function from future_builtins import * ...
7
votes
7answers
583 views

Generator expressions or yield generators?

This is a revisit to a question already asked here about a year and a half ago. While solving Project Euler's Problem 40 I wrote this: def counting_digits(): for number in count(1): for ...
1
vote
2answers
2k views

Python generator function that yields combinations of elements in a sequence sorted by subset order

In Python, itertools.combinations yields combinations of elements in a sequence sorted by lexicographical order. In the course of solving certain math problems, I found it useful to write a function, ...