Securing a future for anonymous functions in Python

Scott David Daniels Scott.Daniels at Acm.Org
Fri Dec 31 20:58:04 CET 2004


David Bolen wrote:
> Scott David Daniels <Scott.Daniels at Acm.Org> writes:
>>     while test() != False:
>>          ...code...
> I'm not sure I follow the "error" in this snippet...

The code is "fat" -- clearer is:
      while test():
           ...code...

>>The right sequence using lambda is:
>>      d = some_deferred_function()
>>      d.addCallback(next_function)
>>      d.addCallback(lambda blah: third_function(otherargs, blah))
>>      d.addCallback(last_function)
> By what metric are you judging "right"?

By a broken metric that requires you to mis-understand the original code
in the same way that I did.  It was an idiotic response that required
more careful reading than I am doing this morning.  The thing I've seen
in too much code (and though I saw in your code) is code like:

    requires_function(lambda: function())

rather than:

    requires_function(function)

It happens quite often, and I'm sure you've seen it.  But I got your
code wrong, and for that I apologize.

--Scott David Daniels
Scott.Daniels at Acm.Org



More information about the Python-list mailing list