Skip to content

Instantly share code, notes, and snippets.

@bcho
Created January 27, 2015 09:17
Show Gist options
  • Select an option

  • Save bcho/8f0907949efff4302e41 to your computer and use it in GitHub Desktop.

Select an option

Save bcho/8f0907949efff4302e41 to your computer and use it in GitHub Desktop.
class A(object):
bounded_lambda = lambda x: x
def __init__(self, unbounded_lambda):
self.unbounded_lambda = unbound_lambda
def __call__(self):
print(self.bounded_lambda, self.unbounded_lambda)
# Cannot run this:
# self.bounded_lambda('just one argument')
A(lambda x: int(x))()
# output:
# <bound method A.<lambda> of <__main__.A object at 0x10da394a8>> <function <lambda> at 0x10d898b70>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment