Created
December 11, 2013 13:13
-
-
Save OrangeTux/7910194 to your computer and use it in GitHub Desktop.
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
# event.py | |
class Event(): | |
# some implentation of adding, deleting and firing event handlers | |
pass | |
class ErrorEvent(Event): | |
pass | |
# some_file.py | |
from event import ErrorEvent | |
def do_something(): | |
ErrorEvent.fire("Temperature is to high") | |
# main.py | |
from event import ErrorEvent | |
from some_file import do_something | |
def handle_error(msg): | |
print("Handled error: %s" % msg) | |
ErrorEvent.add_handler(handle_error) | |
do_something # will print: "Handled error: Temperature to high" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment