Fredrik Lundh <[EMAIL PROTECTED]> wrote: > Alex Martelli wrote: > > > I think I'll scream, though not quite as loud as for my next seeing: > > > > map(lambda x: f(x), ... > > > > instead of > > > > map(f, ... > > note that if you replace "map" with "some function that takes a callable", > the difference between these two constructs may be crucially important.
Sure -- if global name f gets rebound during the execution of the ``some function'' (or if that function stashes the callable away, and that name gets rebound later, etc), the semantics of passing f are different -- to get the same semantics with a lambda, you'd have to use the old trick: somefunc(lambda x, f=f: f(x), ... I don't recall ever having seen the late-binding semantics (of the lambda I originally showed) ``used properly'' -- I _have_ sometimes seen that semantics cause subtle bugs, though. Do you have any real-life examples where expecting and allowing for rebinding of global name `f' is proper and desirable behavior? Being able to show a "good" use of this late-binding could be helpful, if I knew of any. Alex -- http://mail.python.org/mailman/listinfo/python-list