Alex Martelli wrote: > A Ruby example of reimplementing while: > > def WHILE(cond) > | return if not cond > | yield > | retry > | end > i=0; WHILE(i<3) { print i; i+=1 } > > Python's a bit less direct here, but: > > def WHILE(cond): > if not cond(): return > yield None > yield WHILE(cond)
Maybe I misunderstand, but shouldn't this be: def WHILE(cond): if not cond(): return yield None for x in WHILE(cond): yield x After all, the original version only yields two things: None and a generator. (Or is this behavior different in Python 2.5? I hope not...) -- Hans Nowak http://zephyrfalcon.org/ -- http://mail.python.org/mailman/listinfo/python-list