"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>You can't have assignments inside the "lambda" function, but the lambda itself can be used in assignments.</p>

<p>So you can't say something like <code>lambda x: y = x*2; return y</code>, but you can say <code>foo = lambda x: x*2</code></p>

python lambda variable-assignment