[Python-Dev] PEP 3152 and yield from Future() (original) (raw)
Greg Ewing greg.ewing at canterbury.ac.nz
Fri Apr 24 02:49:05 CEST 2015
- Previous message (by thread): [Python-Dev] PEP 3152 and yield from Future()
- Next message (by thread): [Python-Dev] PEP 3152 and yield from Future()
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Victor Stinner wrote:
You didn't answer to my question. My question is: is it possible to implement Future.cocall() since yield is defined in cofunctions. If it's possible, can you please show how? (Show me the code!)
The implementation of a cocall method is not a cofunction, it's an ordinary function that returns an iterator. In the case of Future, what it needs to do is identical to Future.iter. So the code can be just
def __cocall__(self):
return iter(self)
or equivalent.
-- Greg
- Previous message (by thread): [Python-Dev] PEP 3152 and yield from Future()
- Next message (by thread): [Python-Dev] PEP 3152 and yield from Future()
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]