Created
September 8, 2009 10:41
-
-
Save NicolasT/182850 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Parser: | |
def parse(self, text): | |
self.onElement(text[::-1]) | |
def onElement(self, t): | |
raise NotImplementedError | |
def cb_helper(): | |
value = yield | |
yield None | |
yield value | |
def test(): | |
p = Parser() | |
helper = cb_helper() | |
helper.next() | |
p.onElement = helper.send | |
p.parse('abc') | |
value = helper.next() | |
print 'Returned', value | |
test() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment