On 28/04/15 20:39, Paul Sokolovsky wrote:
Hello,
On Tue, 28 Apr 2015 19:44:53 +0100
Mark Shannon <m...@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.
_______________________________________________
Python-Dev mailing list
Python-Dev@python.org
https://mail.python.org/mailman/listinfo/python-dev
Unsubscribe:
https://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com