> it would be > equivalent as if every "val = g2.next()" in g1 was rewritten: > > val = g2.next() > if isinstance(val, magic.Cooperate): > yield val Something bothers me about that proposal, and I think it's this: it would mean that generators are no longer simply a particular technique for implementing iterators, but would have special powers that other iterators don't have. Unless recognising the magic Cooperate value and doing the right thing were made part of the iterator protocol, and all iterators were expected to do the right thing with it, which would be a big imposition. Greg Ewing, Computer Science Dept, +--------------------------------------+ University of Canterbury, | A citizen of NewZealandCorp, a | Christchurch, New Zealand | wholly-owned subsidiary of USA Inc. | greg at cosc.canterbury.ac.nz +--------------------------------------+
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