Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Lambda Functions
#5
It's useful for times when you need some sort of a callable parameter, but you don't actually care about what the param is, or you only need to do something very simple and creating a named function is not needed.  Like event handlers.  Here's some pseudocode to illustrate:
MyButton.onclick(lambda: print('testing'))
In python, lambdas are very limited to the point of being almost completely worthless (only one line, can't have multiple statements, can't assign to variables, etc).  In other languages (such as ruby or javascript), they are used very, very extensively in almost every package.  Because they're so limited in python, you could just never use them, and not be missing anything important.
Reply


Messages In This Thread
Lambda Functions - by ATXpython - Sep-28-2016, 10:29 PM
RE: Lambda Functions - by micseydel - Sep-28-2016, 10:35 PM
RE: Lambda Functions - by ATXpython - Sep-29-2016, 01:44 AM
RE: Lambda Functions - by metulburr - Sep-29-2016, 03:10 AM
RE: Lambda Functions - by nilamo - Sep-29-2016, 03:29 PM
RE: Lambda Functions - by j.crater - Sep-29-2016, 05:58 PM
RE: Lambda Functions - by micseydel - Sep-29-2016, 06:00 PM
RE: Lambda Functions - by j.crater - Sep-29-2016, 06:11 PM
RE: Lambda Functions - by snippsat - Sep-29-2016, 06:42 PM
RE: Lambda Functions - by nilamo - Sep-29-2016, 06:08 PM
RE: Lambda Functions - by nilamo - Sep-29-2016, 06:26 PM
RE: Lambda Functions - by Larz60+ - Sep-29-2016, 06:44 PM
RE: Lambda Functions - by metulburr - Sep-29-2016, 07:03 PM
RE: Lambda Functions - by nilamo - Sep-29-2016, 07:05 PM
RE: Lambda Functions - by snippsat - Sep-29-2016, 08:05 PM
RE: Lambda Functions - by ATXpython - Sep-29-2016, 10:09 PM
RE: Lambda Functions - by Larz60+ - Sep-30-2016, 01:42 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Multiple lambda functions in zipped list not executing psolar 0 1,640 Feb-13-2020, 12:53 PM
Last Post: psolar

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020