Skip to content

Instantly share code, notes, and snippets.

@e000
Created June 13, 2011 22:40
Show Gist options
  • Save e000/1023909 to your computer and use it in GitHub Desktop.
Save e000/1023909 to your computer and use it in GitHub Desktop.
How not to use lambdas.
class Foo:
def __init__(self, a, b, c):
self._a = a
self._b = b
self._c = c
def getA(self):
return self._a
Foo = (lambda(new):
new.classobj('Foo', (), dict(
__init__ = (lambda self, a, b, c:
self.__dict__.update(dict(
_a = a,
_b = b,
_c = c
))
),
getA = lambda self: self._a,
))
)(__import__('new'))
F = Foo(1, 2, 3)
print F.getA()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment