Re: Yield in a wrapper function

2005-11-18 Thread Bengt Richter
On 18 Nov 2005 05:08:39 -0800, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]> wrote: >This works exactly as you would expect:: > > from time import sleep > def foo(on='ABC'): >for e in list(on): >sleep(1) >yield e > >When I run this on the command line It takes about 3 seconds to >com

Re: Yield in a wrapper function

2005-11-18 Thread Peter Otten
[EMAIL PROTECTED] wrote: > from time import sleep > def foo(on): > for e in list(on): Just for e in on: #... is better. The list() constructor defeats much of the laziness you gain by using a generator. > sleep(1) > yield e > > def wrapper(x): > if x < 0: >

Yield in a wrapper function

2005-11-18 Thread [EMAIL PROTECTED]
This works exactly as you would expect:: from time import sleep def foo(on='ABC'): for e in list(on): sleep(1) yield e When I run this on the command line It takes about 3 seconds to complete and the first letter is shown after 1 second. But, how do I wrap the function somew