Steve Holden wrote: > tac-tics wrote: > > [EMAIL PROTECTED] wrote: > > > >>Hey there, > >>i have been learning python for the past few months, but i can seem to > >>get what exactly a lamda is for. What would i use a lamda for that i > >>could not or would not use a def for ? Is there a notable difference ? > >>I only ask because i see it in code samples on the internet and in > >>books. > > > > > > Lambda is just as powerful as a function, but totally useless =-P > > > > Lambda used to be handy before the introduction of list comprehensions. > > Now, though, there primary use is obfuscating your code. > > > I do wish you could hold yourself back and stop muddying the waters. > Lambdas and list comprehensions have little or nothing to do with each > other. Unless you know something I don't ... >
I think he meant that lambda's main use before was inside map and filter; as stated earlier in the thread, lambda's main use was for passing simple functions as arguments, and of these map and filter must have made up a majority (and then I'd guess TKinter would be next). List comprehensions replace map and filter, so... I wouldn't put it as explosively as he has, but I find a lambda less clear than a def too. Iain > regards > Steve > -- > Steve Holden +44 150 684 7255 +1 800 494 3119 > Holden Web LLC/Ltd http://www.holdenweb.com > Skype: holdenweb http://holdenweb.blogspot.com > Recent Ramblings http://del.icio.us/steve.holden -- http://mail.python.org/mailman/listinfo/python-list