Created
June 13, 2011 22:40
-
-
Save e000/1023909 to your computer and use it in GitHub Desktop.
How not to use lambdas.
This file contains hidden or 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
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