[Python-talk] Generator Question
Kent Johnson
kent37 at tds.net
Thu Aug 13 12:42:04 EDT 2009
On Thu, Aug 13, 2009 at 11:58 AM, <bruce.labitt at autoliv.com> wrote:
> Will the group of generators cascade the
> same?
Yes, all that is changing is the source of the first generator (from a
generator function instead of a generator expression).
> Say we use the previous example. Something like this, or would I need to
> do something different?
>
> seeds = [ <some sequence that defines the arrays to be created> ]
> score = 0
> while score < threshold:
> #arrays = (make_array(seed) for seed in seeds)
> arrays = make_array(seed) # instead of line above
> fft_results = (compute_fft(array) for array in arrays)
> powers = (compute_power(result) for result in fft_results)
> score, seeds = optimize(powers)
Right.
> This is really powerful stuff...
Yes :-)
Kent
More information about the Python-talk
mailing list