if the else short form

NevilleDNZ nevillednz at gmail.com
Fri Oct 8 03:13:25 CEST 2010

On Oct 7, 9:23 am, Lawrence D'Oliveiro <l... at geek-
central.gen.new_zealand> wrote:
> x = {1 : "One", 2 : "Two", 3 : "Three"}.get(i, "None Of The Above")

More like:
x = {1:lambda:"One", 2:lambda:"Two", 3:lambda:"Three"}.get(i,
lambda:"None Of The Above")()

i.e. deferred evaluation of selected case.

In Algol68 this would be:
x:=(i|"One","Two","Three"|"None Of The Above")

To download Linux's Algol68 Compiler, Interpreter & Runtime:
* http://sourceforge.net/projects/algol68/files

More information about the Python-list mailing list