In article <[EMAIL PROTECTED]>, The Pythonista <[EMAIL PROTECTED]> wrote: > >Yesterday, I was hacking around a bit, trying to figure out how to >implement the semantics of call/cc in Python. Specifically, I wanted to >translate this Scheme code to equivalent Python: > >#### > >(define theContinuation #f) > > (define (test) > (let ((i 0)) > (call/cc (lambda (k) (set! theContinuation k))) > (set! i (+ i 1)) > i)) > > (test) > (theContinuation) > (theContinuation) >
Python relies on mutables to do this: class holder: pass def call(): x = holder() x.counter = 0 def cc(): x.counter += 1 return x.counter return cc foo = call() print foo() print foo() print foo() -- Aahz ([EMAIL PROTECTED]) <*> http://www.pythoncraft.com/ "as long as we like the same operating system, things are cool." --piranha -- http://mail.python.org/mailman/listinfo/python-list