Skip to content

Instantly share code, notes, and snippets.

@gmarkall
Created April 25, 2011 17:58
Show Gist options
  • Save gmarkall/940900 to your computer and use it in GitHub Desktop.
Save gmarkall/940900 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(self, node):
print "Base implementation"
@visit.when(Scope)
def visit(self, node):
print "Scope"
@visit.when(Statement)
def visit(self, node):
print "Statement"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment