Beispiel #1
0
def wc(next = gsingleton(print__)):
	i=0
	while True:
		try:
			x = yield
		except StopIteration, e:
			next.send(i)
			i=0
		i += 1
Beispiel #2
0
def greps(expression, next = gsingleton(print__)):
	while True:
		try:
			x = yield
			if x.find(expression)!=-1:
				next.send(x)
		except StopIteration, e:
			next.throw(StopIteration())
			i=0
		i += 1