"lambdas can't have assignment statements" - so why is "foo = lambda x: x * 2" legal?
<p>I am reading Functional Python Programming by Steven Lott, a book about using Python 'functionally' instead of in a more object oriented fashion and which focuses on exploratory data analysis for most of its examples.</p>

<p>Lott says that Lamda's can't have assignment statements. But on the same page he assigned a lambda function to a variable:</p>

<pre><code>&gt;&gt;mersenne = lambda x: 2**x-1
&gt;&gt;mersenne(17)
 131071
</code></pre>

<p>How is that not an assignment statement? Is there some other sense of 'assignment' that I am missing?</p>

<p>It's not not an assignment.</p>

<p>A lambda in Python cannot <em>contain</em> an assignment. But this is pretty much the only aspect of Python which enforces a functional paradigm. The rest of the language has some unescapable procedural features; it is hard to imagine a Python program which didn't contain <em>any</em> assignments.</p>

python lambda variable-assignment