At 12:01 PM 10/18/2005 +0100, Gustavo J. A. M. Carneiro wrote: >def show_message(msg): > win = create_window(msg) > animate(win, xrange(10)) # slide down > yield Timeout(3) > animate(win, xrange(10, 0, -1)) # slide up > win.destroy() > > This obviously doesn't work, because calling animate() produces >another generator, instead of calling the function. In coroutines >context, it's like it produces another coroutine, while all I wanted was >to call a function. Just 'yield animate(win, xrange(10))' and have the trampoline recognize generators. See the PEP 342 trampoline example, which does this. When the animate() is exhausted, it'll resume the "calling" function. > I don't suppose there could be a way to make the yield inside the >subfunction have the same effect as if it was inside the function that >called it? Perhaps some special notation, either at function calling or >at function definition? Yes, it's 'yield' at the function calling. :)
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4