Skip to content

Instantly share code, notes, and snippets.

@gmarkall
Created April 25, 2011 11:47
Show Gist options
  • Save gmarkall/940402 to your computer and use it in GitHub Desktop.
Save gmarkall/940402 to your computer and use it in GitHub Desktop.
Example use of the python dispatch package
import dispatch
class Visitor:
@dispatch.on('node')
def visit(node):
print "Base implementation"
@visit.when(Scope)
def visit(node):
print "Scope"
@visit.when(Statement)
def visit(node):
print "Statement"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment