Last active
August 29, 2015 14:07
-
-
Save wolf0403/8edab44b5eaf3078c6b1 to your computer and use it in GitHub Desktop.
Bound method as callback
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import sched, time | |
class O(object): | |
def __init__(self, name): | |
self.name = name | |
def print_time(self): | |
print("({}): From print_time {}".format(self.name, time.time())) | |
def entry(self): | |
s = sched.scheduler(time.time, time.sleep) | |
s.enter(2, 1, self.print_time, ()) | |
s.run() | |
runner = O('runner') | |
runner.entry() | |
# Output: | |
# (runner): From print_time 1412821256.22 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment