Why are assignments not allowed in Python's `lambda` expressions?
This is not a duplicate of Assignment inside lambda expression in Python , i.e., I'm not asking how to trick Python into assigning in a lambda expression. I have some λ-calculus background. Considering the following code, it looks like Python is quite willing to perform side-effects in lambda expressions: #!/usr/bin/python def applyTo42(f): return f(42) def double(x): return x * 2 class ContainsVal: def __init__(self, v): self.v = v def store(self, v): self.v = v def main(): print('== functional, no side effects') print('-- print the double of 42') print(applyTo42(double)) print('-- print 1000