Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- >>> def comunicate():
- ... print("passo1")
- ... i = 0
- ... try:
- ... while True:
- ... yield i
- ... i += 1
- ... except StopIteration:
- ... print "passo3"
- ...
- >>>
- >>> a = comunicate()
- >>> a.next()
- passo1
- 0
- >>> a.next()
- 1
- >>> a.next()
- 2
- >>> a.throw(StopIteration)
- passo3
- Traceback (most recent call last):
- File "<console>", line 1, in <module>
- StopIteration
- >>>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement