Python paradigms

Aahz Maruch aahz at netcom.com
Sun Apr 16 14:04:55 EDT 2000


In article <slrn8fk2kh.965.scarblac-spamtrap at flits104-37.flits.rug.nl>,
Remco Gerlich <scarblac-rt at pino.selwerd.nl> wrote:
>
>Pass functions?
>
>def exp_if(test, true, false):
>  if test: return true()
>  else: return false()
>  
>x = exp_if(a is not None, lambda a=a,i=i: a[i].weeble, lambda: 0)
>
>Getting silly, though :)

It's not so silly if true() and false() are coroutines or generators.
That way you can get rid of the lambda.  ;-)
--
                      --- Aahz (Copyright 2000 by aahz at netcom.com)

Androgynous poly kinky vanilla queer het    <*>     http://www.rahul.net/aahz/
Hugs and backrubs -- I break Rule 6

"First one back from the bathroom gets to be the bottom."



More information about the Python-list mailing list