Re: Question on lambdas

2014-12-09 Thread Christoph M. Becker
Ben Finney wrote: > Christoph Becker writes: > >> Ben Finney wrote: >> >>> It's best to remember that ‘lambda’ is syntactic sugar for creating >>> a function; the things it creates are not special in any way, they >>> are normal functions, not “lambdas”. >> >> Could you please elaborate why ‘lam

Re: Question on lambdas

2014-12-09 Thread Thomas Rachel
Am 09.12.2014 04:09 schrieb memilanuk: so in the first example in my original post: ... lambda: update_label2('A', 100) would this work the same? It looks as though it'd be passing the same two parameters to the same function... lambda: 'A', 100: update_label2() No. Even if it would be all

Re: Question on lambdas

2014-12-09 Thread Dave Angel
On 12/09/2014 02:15 AM, memilanuk wrote: On 12/08/2014 09:30 PM, Ben Finney wrote: memilanuk writes: ... lambda: update_label2('A', 100) would this work the same? (I don't know what you mean here by “the same”; the same as what?) The above creates a new function, which expects no paramete

Re: Question on lambdas

2014-12-08 Thread memilanuk
On 12/08/2014 09:30 PM, Ben Finney wrote: memilanuk writes: ... lambda: update_label2('A', 100) would this work the same? (I don't know what you mean here by “the same”; the same as what?) The above creates a new function, which expects no parameters (because there are no parameters before

Re: Question on lambdas

2014-12-08 Thread Rustom Mody
On Tuesday, December 9, 2014 5:28:49 AM UTC+5:30, Ben Finney wrote: > memilanuk writes: > > > What I'm having trouble finding a concrete answer to is the difference > > between: > > (Note that where you write “some_func” the syntax requires an > expression, not a function. I've changed your examp

Re: Question on lambdas

2014-12-08 Thread Steven D'Aprano
On Tue, 09 Dec 2014 02:44:12 +0100, Christoph Becker wrote: > Ben Finney wrote: > >> It's best to remember that ‘lambda’ is syntactic sugar for creating a >> function; the things it creates are not special in any way, they are >> normal functions, not “lambdas”. > > Could you please elaborate wh

Re: Question on lambdas

2014-12-08 Thread Ben Finney
memilanuk writes: > ... > lambda: update_label2('A', 100) > > would this work the same? (I don't know what you mean here by “the same”; the same as what?) The above creates a new function, which expects no parameters (because there are no parameters before its ‘:’). The function, when called,

Re: Question on lambdas

2014-12-08 Thread Ben Finney
Christoph Becker writes: > Ben Finney wrote: > > > It's best to remember that ‘lambda’ is syntactic sugar for creating > > a function; the things it creates are not special in any way, they > > are normal functions, not “lambdas”. > > Could you please elaborate why ‘lambda’ does not create “lambd

Re: Question on lambdas

2014-12-08 Thread memilanuk
On 12/08/2014 03:58 PM, Ben Finney wrote: memilanuk writes: What I'm having trouble finding a concrete answer to is the difference between: lambda: some_expr This creates a new function which expects zero parameters. The function, when called, will return the value of ‘some_expr’. lam

Re: Question on lambdas

2014-12-08 Thread Terry Reedy
On 12/8/2014 8:53 PM, Chris Angelico wrote: On Tue, Dec 9, 2014 at 12:44 PM, Christoph Becker wrote: Ben Finney wrote: It's best to remember that ‘lambda’ is syntactic sugar for creating a function; the things it creates are not special in any way, they are normal functions, not “lambdas”.

Re: Question on lambdas

2014-12-08 Thread Chris Angelico
On Tue, Dec 9, 2014 at 12:44 PM, Christoph Becker wrote: > Ben Finney wrote: > >> It's best to remember that ‘lambda’ is syntactic sugar for creating a >> function; the things it creates are not special in any way, they are >> normal functions, not “lambdas”. > > Could you please elaborate why ‘la

Re: Question on lambdas

2014-12-08 Thread Christoph Becker
Ben Finney wrote: > It's best to remember that ‘lambda’ is syntactic sugar for creating a > function; the things it creates are not special in any way, they are > normal functions, not “lambdas”. Could you please elaborate why ‘lambda’ does not create “lambdas”. I'm a Python beginner (not new to

Re: Question on lambdas

2014-12-08 Thread MRAB
On 2014-12-08 23:58, Ben Finney wrote: memilanuk writes: What I'm having trouble finding a concrete answer to is the difference between: (Note that where you write “some_func” the syntax requires an expression, not a function. I've changed your examples to be clear). lambda: some_expr Th

Re: Question on lambdas

2014-12-08 Thread Chris Angelico
On Tue, Dec 9, 2014 at 10:58 AM, Ben Finney wrote: >> lambda x=some_value: some_expr > > This creates a new function which expects one parameter named ‘x’, which > parameter has a default value of ‘some_value’. The function, when > called, will return the value of ‘some_expr’. *facepalm* For some

Re: Question on lambdas

2014-12-08 Thread Gary Herron
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 t

Re: Question on lambdas

2014-12-08 Thread Ben Finney
memilanuk writes: > What I'm having trouble finding a concrete answer to is the difference > between: (Note that where you write “some_func” the syntax requires an expression, not a function. I've changed your examples to be clear). > lambda: some_expr This creates a new function which expects

Re: Question on lambdas

2014-12-08 Thread Chris Angelico
On Tue, Dec 9, 2014 at 10:43 AM, memilanuk wrote: > What I'm having trouble finding a concrete answer to is the difference > between: > > lambda: some_func > > lambda e: some_func These two are quite simple. (In each case, it's an expression, not a function, for what it's worth.) They're (roughly

Question on lambdas

2014-12-08 Thread memilanuk
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.Radio