March 17th, 2005, 11:06 AM
Python 3000 -- removing lambda D:
I use lambda a lot w/ wxPython events. What should I use instead? I don't think anything can be as short as using lambda there.
March 17th, 2005, 04:00 PM
Thanks for the link.
Perhaps it's list comprehensions that you're looking for?
Once I needed to use lambda with map() as seen here:
( http://forums.devshed.com/showthread.php?p=940894#post940894 ) just to get map() to work. The list comprehension seems more elegant, at least in this case.
Maybe that's what to use with wxpython? Any examples?
ouch. I did like map and filter... and \'s too... and what's up with input()/raw_input() now?
March 17th, 2005, 04:55 PM
This is indeed a strange turn, obviously I should pay more attention to the PEPs .
Still, for the most part I agree with what's happening: reducing the number of built-in functions & keywords. This makes the language cleaner. Hopefully Python will be fully standardized with this release .
Anyway, as described in the PEP you should stop using lambda, however since this version will be such a large change I doubt that most Python programs will work with it – "print" is to be removed for instance.
I agree with 2k, list comprehension/generator expressions can be used to accomplish anything you can do with map() and lambda expressions in a clearer way.
Because lambda is just a quick way of creating a function it should be fairly easy to expand them to be local/nested functions. You can start to do this now if you like but Python 3 is still only a dream right now, so we'll have to see how it goes.
I wouldn't worry about it too much for now,
March 18th, 2005, 12:17 AM
I'm not sure how I feel about this myself. I'm a Schemer as well as a Pythoner, and lambda is used extensively in Scheme even though nested functions are also available - but that's because Scheme is more or less built from lambdas. Also, in Scheme you can use lambda expressions to generate new functions at runtime, and functions returned by a lambda expression can be passed as functional arguments to other functions; since neither of these are possible with Python lambdas AFAIK, it means there is much less need for them.