On Sun, Oct 14, 2012 at 5:53 PM, Guido van Rossum <guido@python.org> wrote:
A readable version of this could should not have to use lambdas.
In a lot of Twisted code, it happens with methods as callback methods, something like: d = self._doRPC(....) d.addCallbacks(self._formatResponse, self._formatException) d.addCallback(self._finish) That doesn't talk about gatherResults, but hopefully it makes the idea clear. A lot of the legibility is dependant on making those method names sensible, though. Our in-house style guide asks for limiting functions to about ten lines, preferably half that. Works for us. Another pattern that's frowned upon since it's a bit of an abuse of decorator syntax, but I still like because it tends to make things easier to read for inline callback definitions where you do need more than a lambda: d = somethingThatHappensLater() @d.addCallback def whenItsDone(result): doSomethingWith(result) --Guido van Rossum (python.org/~guido)
cheers lvh