conditionals in lambdas?
brk at jenkon.com
Fri Nov 3 22:22:27 CET 2000
One possibility is to use the when function from lazy.py:
>>> 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
lazy.py is part of the Xoltar Toolkit, available at
http://www.sourceforge.net/projects/xoltar-toolkit . 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
> return 0
> I'd like to make something like this a lambda function. Is that possible?
> 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) http://nlug.ca.nortel.com
More information about the Python-list