This file contains 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
#!/usr/bin/env python | |
"""Sample script which uses event.py (improved). """ | |
import event | |
class Publisher(object): | |
# Set event object in class declaration. |
This file contains 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
#!/usr/bin/env python | |
"""Sample script which uses event.py (simple). """ | |
import event | |
class Publisher(object): | |
def __init__(self): |
This file contains 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
# event.py (simple) | |
class Event(object): | |
def __init__(self): | |
self.handlers = [] | |
def add(self, handler): | |
self.handlers.append(handler) | |
return self |
This file contains 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
# event.py (improved) | |
class Event(object): | |
def __init__(self, doc=None): | |
self.__doc__ = doc | |
def __get__(self, obj, objtype=None): | |
if obj is None: | |
return self |
NewerOlder