[ create a new paste ] login | about

Link: http://codepad.org/6lRzdC4K    [ raw code | fork ]

Python, pasted on Mar 6:
>>> def yielder():
	while 1:
		a=yield 'a'
		print ('yielder: '+str(a))
		if a=='asd':
			return 'yielder return'

	
>>> a=BinaryTree(yielder())
>>> b=iter(a)
>>> b.send(None)
'a'
>>> b.send(None)
yielder: None
'a'
>>> b.send(None)
yielder: None
'a'
>>> b.send(54)
yielder: 54
'a'
>>> b.send(54)
yielder: 54
'a'
>>> b.throw(StopIteration)
binary: None
Traceback (most recent call last):
  File "<pyshell#57>", line 1, in <module>
    b.throw(StopIteration)
StopIteration

>>> a=BinaryTree(yielder())
>>> b=iter(a)
>>> b.send(None)
'a'
>>> b.send(54)
yielder: 54
'a'
>>> b.send('asd')
yielder: asd
binary: yielder return
Traceback (most recent call last):
  File "<pyshell#64>", line 1, in <module>
    b.send('asd')
StopIteration


Create a new paste based on this one


Comments: