A replacement for lambda

Paul Rubin http
Sat Jul 30 21:04:23 CEST 2005

Seth Nielson <sethjn at gmail.com> writes:
> Any replacement must support the following: *delayed evaluation*.
> I need a convenient (def is not always convenient) way of saying,
> "don't do this now". That is why I use lambda.

How's this: f{args} (curly braces instead of parens) is the same as
f(lambda: args).



    b = Button{callback=pressed()}   # Button remembers callback()

    def ternary(cond, x, y):
       if cond(): return x()
       else: return y()

    sign_of_a = ternary{a < 0, -1, 1}


More information about the Python-list mailing list