Lambda function: why do I need a parameter in eventhandlers but not in Button-commands?
<p>In the following case of a Python lambda call, I need to set a parameter for the function to work properly:</p>

<pre><code>name = Entry(self.new_jobtile, width=30)
...
name.bind('&lt;Return&gt;', lambda x:self.create_tile(name.get()))
</code></pre>

<p>However, if I use a Button instead, the very same lambda call works without the "x" parameter:</p>

<pre><code>Button(self.new_jobtile, text="OK", command=lambda: self.create_tile(name.get()), width=4, height=2).pack(side=BOTTOM, pady=3, padx=5)
</code></pre>

<p>I really don't understand why?</p>

<p>In Python you can create lambda function without arguments:</p>

<pre><code>bar = lambda : 4*2
bar() # 8
</code></pre>

<p>I do not know what library are you using but I think that in <code>name.bind</code> second argument should be function with one parameter (like <code>lambda x:</code> or <code>def foo(x):</code>) but in <code>Button</code> constructor argument <code>command</code> should be function with 0 parameters (like <code>lambda :</code> or <code>def foo():</code>).</p>

python lambda