PEP 308: A PEP Writer's Experience - PRO

Roman Suzi rnd at onego.ru
Sun Feb 9 12:17:49 EST 2003


>
>Samuele> ife = lambda box: box[0]
>
>Samuele> z = ife(cond and [x] or [y])

What about my:

# implementation:
def my_if(cond, yes, no):
  if cond: return yes()
  else: return no()

# usage:
k = my_if(cond, lambda:"YES", lambda:"NO")


if we change lambda in to !:

k = my_if(cond, !:"YES", !:"NO")


Sincerely yours, Roman Suzi
-- 
rnd at onego.ru =\= My AI powered by Linux RedHat 7.3






More information about the Python-list mailing list