Skip to content

Instantly share code, notes, and snippets.

@jonty-comp
Created October 15, 2013 09:27
Show Gist options
  • Save jonty-comp/6989009 to your computer and use it in GitHub Desktop.
Save jonty-comp/6989009 to your computer and use it in GitHub Desktop.
Example of simple callback / lambda function default thing in python2.
from __future__ import print_function
class AccessControl:
def __init__(self, **kwargs):
self.on_grant = kwargs.get('on_grant', lambda: print(1) )
def grant(self):
self.on_grant()
a = AccessControl(on_grant = lambda: print(2))
a.on_grant = lambda: print(3)
a.grant()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment