peter at engcorp.com
Tue Mar 11 22:54:59 CET 2003
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?
Python 2.0 (#8, Oct 16 2000, 17:27:58) [MSC 32 bit (Intel)] on win32
>>> name = "a title"
>>> title = lambda s: "<title>%s</title>" % s
>>> print title(name)
More information about the Python-list