On 28/04/15 20:39, Paul Sokolovsky wrote: > Hello, > > On Tue, 28 Apr 2015 19:44:53 +0100 > Mark Shannon <mark at hotpy.org> wrote: > > [] > >> A coroutine without a yield statement can be defined simply and >> concisely, thus: >> >> @coroutine >> def f(): >> return 1 > > [] > >> A pure-python definition of the "coroutine" decorator is >> given below. >> > > [] > >> from types import FunctionType, CodeType >> >> CO_COROUTINE = 0x0080 >> CO_GENERATOR = 0x0020 >> >> def coroutine(f): >> 'Converts a function to a generator function' >> old_code = f.__code__ >> new_code = CodeType( >> old_code.co_argcount, >> old_code.co_kwonlyargcount, > > > This is joke right? Well it was partly for entertainment value, although it works on PyPy. The point is that something that can be done with a decorator, whether in pure Python or as builtin, does not require new syntax. Cheers, Mark.
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