(test) ? a:b

Marko Rauhamaa marko at pacujo.net
Thu Oct 23 12:20:03 EDT 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 {
        gsave
        0.85 1 0.85 setrgbcolor
        fill
        grestore
    } if

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


Marko



More information about the Python-list mailing list