[Python-Dev] Re: Re: anonymous blocks
Fredrik Lundh
fredrik at pythonware.com
Wed Apr 20 08:55:03 CEST 2005
Shane Hathaway wrote:
> Brian's suggestion makes the code read more like an outline. In Brian's
> example, the high-level intent stands out from the details
that assumes that when you call a library function, the high-level intent of
*your* code is obvious from the function name in the library, and to some
extent, by the argument names chosen by the library implementor.
I'm not so sure that's always a valid assumption.
> while in your example, there is no visual cue that distinguishes the details
> from the intent.
carefully chosen function names (that you chose yourself) plus blank lines
can help with that.
> Of course, lambdas are even better, when it's possible to
> use them:
>
> doFoo((lambda a, b: a + b), (lambda c, d: c + d))
that only tells you that you're calling "doFoo", with no clues whatsoever to
what the code in the lambdas are doing. keyword arguments are a step up
from that, as long as your intent matches the library writers intent.
</F>
More information about the Python-Dev
mailing list