lambda question
David Bear
david.bear at asu.edu
Tue Mar 11 16:54:55 EST 2003
<posted & mailed>
David Bear wrote:
> I was hoping to use lambda to create some quick string transforming
> functions. So I did :
>
> name = "a title"
> title = lambda s: "<title> % </title>" % s
> print title(name)
> Traceback (most recent call last):
> File "<stdin>", line 1, in ?
> File "<stdin>", line 1, in <lambda>
>
> I don't understand this. Is lambda not a good way to do this? I was
> hoping to avoid function overhead by creating some anonymous functions,
> but I guess I don't understand how to use them.. any comments?
Solved my problem. I was missing the s after the first %. Still I am
wondering if this is a valid use of the lambda function. Anyone have
comments on where lambda's are most usefull?
More information about the Python-list
mailing list