PEP 312 - Making lambdas implicit worries me, surely it's just the name 'lambda' that is bad...

Bengt Richter bokr at oz.net
Sat Mar 15 11:59:21 EST 2003


On Tue, 11 Mar 2003 16:58:01 +0100, "Daniel Dittmar" <daniel.dittmar at sap.com> wrote:

>A. Lloyd Flanagan wrote:
>> Part of the problem, I think, is that people coming from other
>> languages don't understand the power and proper use of the lambda
>> construct.
>
>coming from Smalltalk:
>Python lambdas are restricted to one expression, which makes them cumbersome
>to use for more complex stuff and difficult to debug as you can't insert a
>quick 'print'.
>
Whatever the restrictions, you can arrange for "a quick print'," e.g.,

    def qp(x): print x; return x

or even

    def qp(fmt, x): print fmt % x; return x

I.e., use
    qp(expression_term)
in place of
    expression_term
to get "a quick 'print'" of an expression term.

Regards,
Bengt Richter




More information about the Python-list mailing list