Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $ cat else.py
- #! /usr/bin/python
- def foo():
- yield 1
- yield 2
- yield 3
- f = foo()
- stop = False
- while not stop:
- try:
- print f.next()
- print "else"
- except StopIteration:
- print 'stop'
- stop = True
- print 'after'
- $ python else.py
- 1
- else
- after
- 2
- else
- after
- 3
- else
- after
- stop
- after
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement