[Python-Dev] any support for a methodcaller HOF?

"Martin v. Löwis" martin at v.loewis.de
Sun Feb 5 14:09:22 CET 2006


Nick Coghlan wrote:
> I guess my point is that expressions are appropriate sometimes, functions are 
> appropriate other times, and it *is* possible to give reasonably simple 
> guidelines as to which one is most appropriate when (one consumer->deferred 
> expression, multiple consumers->named function).

I don't think this guideline is really valuable. If you transfer this to
variables, you would get "one reader -> inline expression, multiple
readers -> named variable".

This is clearly wrong: it is established practice to use local variables
even if there is only one access to the variable, if creating the
variable improves readability of the code (e.g. if the expression is
very complex).

For functions, the same should hold: if it improves readability, make it
a local function.

Regards,
Martin


More information about the Python-Dev mailing list