Steve Holden wrote: > [EMAIL PROTECTED] wrote: > > "Gary Herron" <[EMAIL PROTECTED]> wrote in message > > news:[EMAIL PROTECTED] > > > >>--snip-- > >>So just use a def. It is constantly pointed out on > >>this list that the lambda provides no extra expressive power, it is > >>merely a shortcut > > > > > > No, it is not merely a shortcut. It often allows one to avoid > > polluting > > the namespace with a completely superfluous function name, thus > > reducing code smell. It can also avoid a multi-line function defintion > > which often pushes other relevant code off the current page and > > out of view, and thus lambda can increase program readability. > > > I'm getting a little tired of "namespace pollution" being trotted out as > a reason to use lambda. Defining a function, and giving it a name, isn't > "polluting the namespace", any more than assigning sub-expressions to > temporary variables is polluting the namespace. Why use temporary > variables when all you have to do is make your expressions three lines > long to avoid "polluting the namespace"?
I agree, if I were to name my function `shuffle', then I wouldn't be able to name any of my intermediate functions `shuffle'! Oh the humanity! Therefore I will instead use adhere to my 0 namespace pollution policy and use this instead: __nopollution_at__all_portion = range(50) __nopollution_at__all_word = 'mint white chocolate chip' if __name__ == '__main__': print (lambda portion,word:(lambda x,word:[x.pop() for i in range(len(word))]+x)((lambda x,word:[x.pop() for i in range(len(word))]+x)((lambda x,word:[x.pop() for i in range(len(word))]+x)((lambda x,word:[x.pop() for i in range(len(word))]+x)(portion[:],word),word),word),word))(__nopollution_at__all_portion,__nopollution_at__all_word) ;-) -- http://mail.python.org/mailman/listinfo/python-list