Advertisement
Guest User

Untitled

a guest
Jan 26th, 2015
177
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.91 KB | None | 0 0
  1. #!/usr/bin/python
  2.  
  3. import time
  4.  
  5. def f():
  6. print "f(): Function 'f' has been called"
  7. print "f(): I can do a bunch of junk here"
  8. print "f(): Maybe start reading in a file line by line"
  9. print "f(): Going to sleep for 2 seconds\n"
  10. time.sleep(2)
  11.  
  12. print "f(): About to yield for first time"
  13. yield 1
  14. print "f(): Have yielded once already, lets do it again"
  15. yield 2
  16. print "f(): Have yielded twice now, one more time"
  17. yield 3
  18. print "f(): Have yielded three times now, and that was the last time, not going to return any more data, going to sleep for 5 seconds"
  19. time.sleep(5)
  20.  
  21. print "main: Program Started"
  22. print "main: About to start loop"
  23. for val in f():
  24. print "main: Got value: %i, lets pause for a couple of seconds before continuing the loop\n" % (val)
  25. time.sleep(2)
  26.  
  27. print "main: Finished looping, lets end the program"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement