Skip to content

Instantly share code, notes, and snippets.

@chrisdickinson
Created July 7, 2010 23:13
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save chrisdickinson/467430 to your computer and use it in GitHub Desktop.
Save chrisdickinson/467430 to your computer and use it in GitHub Desktop.
class Fab(object):
def __enter__(self):
self._stack = []
return self
def __exit__(self, *args, **kwargs):
print self._stack
def __call__(self, *args):
self._stack += args
return self
def tmpl(self):
print "tmpl\t", self
return self
def listen(self, *args):
print "listen\t", self
return self
with Fab() as fab:
(fab)\
(listen, 0xFAB)\
(r'^hello/$')(tmpl)\
( "hello, {{ self }}")\
(r'(?P<what>\w+)/$')(tmpl)\
( "hello, {{ self.what }}")\
(404)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment