Mike Meyer mwm at
Mon Jan 20 18:13:33 CET 2003

Gregor <palam_POOP_edes at> writes:

> I came across an introduction to Stackless Python and continuations which 
> piqued my interest. It gave the following example to illustrate how a 
> continuation works:
> def looptest(n):
>     this = continuation.current()
>     k = this.update(n)
>       # continuation at "="
>     if k:
>         this(k-1)
>         # resuming at "="
>     else:
>         del
> Can anyone tell what "this.update(n)" is, does, or represents? I 
> understand the basic idea of what a continuation is, but that by itself 
> isn't enough background for me to guess what all the terms mean.

Chirtian said stackless Python no longer uses continuations, so you
may want to ignore this. What I think is missing is a comment about
what's returned.

this.update captures the state of the computation and saves it in
this, so that the return from this.update will happen every time this
is called. The value returned by the capture is n. The value returned
by invocations of this is the argument to this.

You are not expected to understand this.         (Unix kernel hackers joke.)

Mike Meyer <mwm at>
Independent WWW/Perforce/FreeBSD/Unix consultant, email for more information.

More information about the Python-list mailing list