Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #82160 > unrolled thread
| Started by | Gary Herron <gherron@digipen.edu> |
|---|---|
| First post | 2014-12-08 15:52 -0800 |
| Last post | 2014-12-08 15:52 -0800 |
| Articles | 1 — 1 participant |
Back to article view | Back to comp.lang.python
This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by
below is the oldest one visible, not the original post.
Re: Question on lambdas Gary Herron <gherron@digipen.edu> - 2014-12-08 15:52 -0800
| From | Gary Herron <gherron@digipen.edu> |
|---|---|
| Date | 2014-12-08 15:52 -0800 |
| Subject | Re: Question on lambdas |
| Message-ID | <mailman.16746.1418083206.18130.python-list@python.org> |
On 12/08/2014 03:43 PM, memilanuk wrote:
>
> So... I was browsing some questions on reddit, and one of them
> involved tkinter and lambdas. Managed to help the person out, but in
> the process ended up with more questions of my own :/
>
> My basic confusion revolves around this: in one instance I see things
> like the following:
>
> R1 = tk.Radiobutton(root, text='A', value=100, variable=var,
> command=lambda: update_label2('A', 100))
>
> and in another example I see things like this:
>
> class MyText(Text):
> def __init__(self, master, **kw):
> apply(Text.__init__, (self, master), kw)
> self.bind("<Return>", lambda e: "break")
>
>
> What I'm having trouble finding a concrete answer to is the difference
> between:
>
> lambda: some_func
A function to be called with no parameters
>
> lambda e: some_func
A function to be called with one parameter
>
> lambda e=e: some_func
A function to be called with one or zero parameters. In the case of a
call with no parameters, a default value has been supplied. The e=e may
be slightly confusing, because 'e' is used in two contexts, one for the
name of the parameter inside the function, and the other the name of the
supplied default value (from the outer scope).
>
> Any help would be greatly appreciated.
>
> TIA,
>
> Monte
>
Hope that helps,
Gary Herron
--
Dr. Gary Herron
Department of Computer Science
DigiPen Institute of Technology
(425) 895-4418
Back to top | Article view | comp.lang.python
csiph-web