Jeff Schwab <[EMAIL PROTECTED]> writes: > def mkadder(n): > return lambda x: x + n > > I have gotten the impression that this was somehow inferior in Python > though, at least in terms of performance. Every time somebody uses > lambda here, they seem to get a bunch "why are you using lambda?" > responses. If I am grossly mistake, please just enlighten me.
There are some Python users who object to lambda on stylistic grounds, and would rather that you say def mkdadder(n): def adder(x, n): return x + n return adder Those same users tend to object to higher-order functions (preferring listcomps or genexps). It seems to me though that Python is moving more towards HOF-oriented styles because of the utility of HOF's over iterators (look at itertools). That might make its learning curve steeper for beginners; I don't have a good sense of this. > I note from your other posts that you seem to have a strong Lisp > bent. Lisp programmer and Smalltalk programmers stand out in the > crowd. I first noted this when somebody found a while-loop offensive, > on the grounds that recursion was somehow a more natural way to > implement looping. It can take a while to convince somebody like that > they different idioms work best in different languages. Well, the saying is "to iterate is human; to recurse, divine" ;-). Scheme has while-loops but they are just syntax sugar for recursion. -- http://mail.python.org/mailman/listinfo/python-list