On 23 Mar 2005 08:31:36 GMT Antoon Pardon <[EMAIL PROTECTED]> wrote: > Can someone who thinks this way, please explain why this is acceptable > > [ x * x for x in some_iterator ] > > But this is not > > map(lambda x: x * x, some_iteraror) > > and should be replaced with > > def sqr(x): return x * x > map(sqr , some_iterator)
I guess I have similar feelings. I've only been using python for a year or two, so I'm still a relative newcomer. Like a lot of people, I found Python to be magically simple and intuitive. But I've never really found list comprehensions particularly clear. I don't know whether it's my backgroud (mainly C/C++), or my brain or what, but they are probably the only thing in Python that hasn't seemed transparent and obvious to me (apart from shadowing of variables in nested functions). Of course, I'm sure I could get used to them, given time. But that rather defeats one of the main reasons for using python in the first place - the lack of a steep learning curve. In contrast, I find lambdas, even with their significant restrictions, to be much more obvious. In fact, the proposal (sorry, don't have a link to hand) about extending lambda to allow things like `myfn = def <indented block>' was something that I initially assumed would become part of the language in time. Is there some definitive information that explains why python is moving away from lambdas and towards things like list comprehensions? - Julian -- http://www.op59.net/ -- http://mail.python.org/mailman/listinfo/python-list