[Python-ideas] Yield-from example: A parser
solipsis at pitrou.net
Wed Feb 18 00:18:09 CET 2009
Greg Ewing <greg.ewing at ...> writes:
> If everything could always be done using pulls, there
> would be no need for send() in the first place.
Sorry if I'm missing something, but send() allows a bidirectional exchange of
values, it doesn't seem to matter whether you pull or you push.
> Not sure what you mean by that. There's no single place
> in the parser that loops until the input is exhausted.
for m in pat.finditer(text):
token = m.group(0)
print "Feeding:", repr(token)
yield None # to signal EOF
def parse_items(closing_tag = None):
elems = 
token = token_stream.next()
if not token:
break # EOF
It looks like parse_items pulls from token_stream until exhaustion.
More information about the Python-ideas