how to make a generator use the last yielded value when it regains control

Lonnie Princehouse finite.automaton at gmail.com
Mon Apr 10 13:05:40 EDT 2006


> What's wrong with the following ?
>
> def morris(seed,n) :
>     """..."""
>     for k in xrange(n-1) :
>         seed=length_encode(seed)
>     return seed

Nothing's wrong with it.

I happen to think the recursive version is more elegant, but that's
just me ;-)




More information about the Python-list mailing list