Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #82177
| From | Ben Finney <ben+python@benfinney.id.au> |
|---|---|
| Subject | Re: Question on lambdas |
| Date | 2014-12-09 16:30 +1100 |
| References | <m65d2m$3pe$1@ger.gmane.org> <85oarditil.fsf@benfinney.id.au> <m65p52$k7m$1@ger.gmane.org> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.16760.1418103009.18130.python-list@python.org> (permalink) |
memilanuk <memilanuk@gmail.com> 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, will return the value of the expression
‘update_label2('A', 100)’.
> It looks as though it'd be passing the same two parameters to the same
> function...
Yes, it looks that way, and that's what it does. The parameters are
fixed in the expression and will be the same each time the new function
is called.
> lambda: 'A', 100: update_label2()
This is a syntax error.
Have you tried experimenting with these? Carefully read the reference
material on the ‘lambda’ syntax, and create some functions and
experiment with them.
--
\ “Not to be absolutely certain is, I think, one of the essential |
`\ things in rationality.” —Bertrand Russell |
_o__) |
Ben Finney
Back to comp.lang.python | Previous | Next | Find similar | Unroll thread
Re: Question on lambdas Ben Finney <ben+python@benfinney.id.au> - 2014-12-09 16:30 +1100
csiph-web