Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #82160
| Path | csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!news.albasani.net!news.stack.nl!newsfeed.xs4all.nl!newsfeed1a.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail |
|---|---|
| Return-Path | <gherron@digipen.edu> |
| X-Original-To | python-list@python.org |
| Delivered-To | python-list@mail.python.org |
| X-Spam-Status | OK 0.025 |
| X-Spam-Evidence | '*H*': 0.95; '*S*': 0.00; 'parameters': 0.04; 'subject:Question': 0.07; 'tkinter': 0.07; '(self,': 0.09; 'function,': 0.09; 'parameter': 0.09; 'tia,': 0.09; 'def': 0.12; 'contexts,': 0.16; 'lambda': 0.16; 'lambda:': 0.16; 'parameters,': 0.16; 'supplied': 0.16; 'wrote:': 0.18; 'slightly': 0.19; 'example': 0.22; 'header:User-Agent:1': 0.23; 'this:': 0.26; 'header:In-Reply-To:1': 0.27; 'function': 0.29; 'appreciated.': 0.29; "i'm": 0.30; 'gary': 0.31; 'parameters.': 0.31; 'class': 0.32; 'another': 0.32; 'trouble': 0.34; 'skip:_ 10': 0.34; 'basic': 0.35; 'but': 0.35; 'two': 0.37; 'received:10': 0.37; 'to:addr:python-list': 0.38; 'pm,': 0.38; '(from': 0.39; 'to:addr:python.org': 0.39; 'called': 0.40; 'skip:u 10': 0.60; 'hope': 0.61; 'name': 0.63; 'more': 0.64; 'charset:windows-1252': 0.65; 'default': 0.69; 'institute': 0.72; 'received:10.10': 0.74; 'received:204': 0.75; 'dr.': 0.77; 'monte': 0.84; 'so...': 0.84; 'browsing': 0.91 |
| Date | Mon, 08 Dec 2014 15:52:11 -0800 |
| From | Gary Herron <gherron@digipen.edu> |
| User-Agent | Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.3.0 |
| MIME-Version | 1.0 |
| To | python-list@python.org |
| Subject | Re: Question on lambdas |
| References | <m65d2m$3pe$1@ger.gmane.org> |
| In-Reply-To | <m65d2m$3pe$1@ger.gmane.org> |
| Content-Type | text/plain; charset=windows-1252; format=flowed |
| Content-Transfer-Encoding | 7bit |
| X-BeenThere | python-list@python.org |
| X-Mailman-Version | 2.1.15 |
| Precedence | list |
| List-Id | General discussion list for the Python programming language <python-list.python.org> |
| List-Unsubscribe | <https://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe> |
| List-Archive | <http://mail.python.org/pipermail/python-list/> |
| List-Post | <mailto:python-list@python.org> |
| List-Help | <mailto:python-list-request@python.org?subject=help> |
| List-Subscribe | <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.16746.1418083206.18130.python-list@python.org> (permalink) |
| Lines | 56 |
| NNTP-Posting-Host | 2001:888:2000:d::a6 |
| X-Trace | 1418083206 news.xs4all.nl 2925 [2001:888:2000:d::a6]:34233 |
| X-Complaints-To | abuse@xs4all.nl |
| Xref | csiph.com comp.lang.python:82160 |
Show key headers only | View raw
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 comp.lang.python | Previous | Next | Find similar | Unroll thread
Re: Question on lambdas Gary Herron <gherron@digipen.edu> - 2014-12-08 15:52 -0800
csiph-web