I'm starting to learn Python and I've come across generator functions, those that have a yield statement in them. I want to know what types of problems that these functions are really good at solving.
...
An interview question for a .NET 3.5 job is "What is the difference between an iterator and an enumerator"?
This is a core distinction to make, what with LINQ, etc.
Anyway, what is the difference? I can't seem to find a solid definition on the net. Make no mistake, I can find the meaning of the two terms but I get slightly different an...
Hello people,
I'm using a python generator function to provide me with a list of images in the current directory. However I see the function is giving out the entire list twice instead of one time and I have no idea why. I'm using the Python PIL library to create batch thumbnails.
Can anyone point me in the right direction?
Thanks in ...
I was working with generator functions and private functions of a class. I am wondering
Why when yielding (which in my one case was by accident) in __someFunc that this function just appears not to be called from within __someGenerator. Also what is the terminology I want to use when referring to these aspects of the language?
Can the ...
Let's say I have a generator function like this:
import random
def big_gen():
i = 0
group = 'a'
while group != 'd':
i += 1
yield (group, i)
if random.random() < 0.20:
group = chr(ord(group) + 1)
Example output might be:
('a', 1), ('a', 2), ('a', 3), ('a', 4), ('a', 5), ('a', 6), ('a', 7), ('a', 8), ('b', 9), ('...
C# has generator functions which have syntax like:
IEnumerable<int> GetNats(int max)
{
for (int i=0; i < max; ++i)
yield return i;
}
A feature I am interested in for my programming language (a simple object-oriented programming similar to Java, Scala, ActionScript, and C#) are generator expressions. These are essentially syn...
If I have a programming language with first class functions. What should the semantics be when a generator function is shared?
For example:
var f = function() {
foreach (i in 0..42)
yield i;
}
int a = f(); // 0
int b = f(); // 1
// Assigning the generator function
var g = f;
int c = g(); // ??
int d = f(); // ??
I can i...
I am interested in defining a parallel map operator for my language. It transforms a list into a new list given an expression. It would have a syntax similar to a generator. Unlike generators in C# and Python, it would potentially be evaluated in parallel, if the compiler desires (e.g. there is an idle core, and the list is really big). ...
I have a PDF copy of a file for creating a report. Based on this form, we will generate a report.
Is there any way that I can fill out the needed fields on the PDF form using python? How?
...
Sorry to double my earlier question, but I thought to ask specific data which would solve the problem. I want this result
tuple_of_vars = (item for _, item for zip(tuple_of_vars, new_vals_generator))
as this is not possible
a, b, c, d = (val for val in infite_generator)
actually then I want to do in single line
for var in var_list...
I'm looking for a very simple way to implement fibers in Python. I'm sure there's a really simple way to do it using generators, but my mind is crapping out on me. This isn't for a huge application, so I don't need the fanciness (or the overhead) of something like Diesel or Tornado or Twisted, I just want a neat little way to do fibers. ...