Advertisement
Guest User

Untitled

a guest
Jul 20th, 2017
57
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.36 KB | None | 0 0
  1. $ cat else.py
  2. #! /usr/bin/python
  3.  
  4. def foo():
  5.     yield 1
  6.     yield 2
  7.     yield 3
  8.  
  9. f = foo()
  10. stop = False
  11. while not stop:
  12.     try:
  13.         print f.next()
  14.         print "else"        
  15.     except StopIteration:
  16.         print 'stop'
  17.         stop = True
  18.    
  19.     print 'after'
  20.  
  21. $ python else.py
  22. 1
  23. else
  24. after
  25. 2
  26. else
  27. after
  28. 3
  29. else
  30. after
  31. stop
  32. after
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement