Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/python
- import time
- def f():
- print "f(): Function 'f' has been called"
- print "f(): I can do a bunch of junk here"
- print "f(): Maybe start reading in a file line by line"
- print "f(): Going to sleep for 2 seconds\n"
- time.sleep(2)
- print "f(): About to yield for first time"
- yield 1
- print "f(): Have yielded once already, lets do it again"
- yield 2
- print "f(): Have yielded twice now, one more time"
- yield 3
- 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"
- time.sleep(5)
- print "main: Program Started"
- print "main: About to start loop"
- for val in f():
- print "main: Got value: %i, lets pause for a couple of seconds before continuing the loop\n" % (val)
- time.sleep(2)
- print "main: Finished looping, lets end the program"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement