(test) ? a:b

Marko Rauhamaa marko at pacujo.net
Thu Oct 23 18:20:03 CEST 2014

Alain Ketterlin <alain at dpt-info.u-strasbg.fr>:

>>     j = (lambda: 3, lambda: j + 1)[j < 10]()
> This is just a way to delay evaluation *of the potential results*,
> i.e., instill a bit of lazyness.

That's one way to characterize a function, or code in general.

That point of view is apparent in PostScript, where control structures
are expressed "lazily" with lambdas:

    5 eq {
        0.85 1 0.85 setrgbcolor
    } if

The { ... } block is a piece of code pushed onto the stack.


More information about the Python-list mailing list