conditionals in lambdas?

Bryn Keller brk at
Fri Nov 3 22:22:27 CET 2000

One possibility is to use the when function from

>>> from lazy import *
>>> filterloaddata = lambda x:when(x[:9] == "#LOADDATA", 1, 0)

The when function also works with lazy expressions, which is why it's in the lazy
module. is part of the Xoltar Toolkit, available at . The package also contains
other tools that someone who's keen on lambdas might appreciate.

Hope that helps,


"Michael P. Soulier" wrote:

>     Hey people. If I want to put conditions in a lambda function, how would I
> go about that?
> def test(string):
>     if string[:3] == 'yes:
>         return 1
>     else:
>         return 0
>     I'd like to make something like this a lambda function. Is that possible?
>     Mike
> --
> Michael P. Soulier, TD12, SKY  Tel: 613-765-4699 (ESN: 39-54699)
> Optical Networks, Nortel Networks, SDE Pegasus
> "...the word HACK is used as a verb to indicate a massive amount
> of nerd-like effort."  -Harley Hahn, A Student's Guide to UNIX
> Nortel Linux User's Group Ottawa: (internal)

More information about the Python-list mailing list