[Tutor] map, filter and lambda functions
alan.gauld@bt.com
alan.gauld@bt.com
Thu, 23 Aug 2001 10:02:31 +0100
> :You don't need to put lambda functions, you can just provide
> :string.strip and string.upper without using lambda what-so-ever.
>
> Are you sure that you can do this without lambda? I tried today, and
> couldn't get it to work without lambda.
>
> >>> mylist
> ['a', 'b', 'c', '']
> >>> mylist = map(string.upper(x), mylist)
Try:
mylist = map(string.upper, mylist)
Its like function pointers in C (Since I know you know C :-) in that
you just use the name - no parens. It is after all a pointer to a
function that you are passing (actually a reference to a callable
object to be pedantic...)
Alan G