generators improvement
Oleg Leschov
kalmas at udm.ru
Tue Aug 19 12:17:24 EDT 2003
Here is a simple idea to make generators more useful for some applications,
although I won't for now name them..
anyways, advantage of current generators was not too obvious for all the
people, too.
So, currently the interface between generator and it's user program is rather
poor, because it only consists of a signal from a user routine, and a kind
of only one directional data passage - from the generator.
This seems unsymmetric to me, and thus incomplete..
What I think should increase the potential usefulness of a generators,
is bi-directional data passage. This is very easy to implement, IMHO.
What needs to be done is to allow yield return something - whatever was
passed to the .next() thing from caller..
Easy and obvious, isn't it? So is there any principal problem with this
idea that would prevents its implementation?
I understand that this can be achieved by using some
global, for instance, but hey, I used to implement generator's functionality
without using them, too - just make a class and make
algorithm look horrible. The same thing, but much wordier and uglier
looking... and that does not mean that generators are redundant.
More information about the Python-list
mailing list