Created
October 15, 2013 09:27
-
-
Save jonty-comp/6989009 to your computer and use it in GitHub Desktop.
Example of simple callback / lambda function default thing in python2.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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