[Python-Dev] Issues with PEP 482 (1) (original) (raw)
Mark Shannon mark at hotpy.org
Tue Apr 28 22:00:17 CEST 2015
- Previous message (by thread): [Python-Dev] Issues with PEP 482 (1)
- Next message (by thread): [Python-Dev] Issues with PEP 482 (1)
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
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 COCOROUTINE = 0x0080 COGENERATOR = 0x0020 def coroutine(f): 'Converts a function to a generator function' oldcode = f.code newcode = CodeType( oldcode.coargcount, oldcode.cokwonlyargcount, 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.
- Previous message (by thread): [Python-Dev] Issues with PEP 482 (1)
- Next message (by thread): [Python-Dev] Issues with PEP 482 (1)
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]