Skip to content

Instantly share code, notes, and snippets.

@chrisallick
Created May 21, 2013 01:27
Show Gist options
  • Save chrisallick/5616940 to your computer and use it in GitHub Desktop.
Save chrisallick/5616940 to your computer and use it in GitHub Desktop.
not happy with this, but lambdas are only a single line and you cannot pass anonymous functions in python :(
from __future__ import print_function
events = {}
def fireEvent(event,msg):
events[event](msg)
def addEvent(event,type,func):
events[event] = func
def onCompass(msg):
print(msg)
addEvent("compass","string",onCompass)
fireEvent( "compass", "wazzsup" )
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment