Apply and map function

Sean 'Shaleh' Perry shalehperry at attbi.com
Thu Jul 18 15:47:40 EDT 2002


On 18-Jul-2002 Nico de Boer wrote:
> Hi all,
> 
> I want to implement the apply or map function into the following code:
> 
>         initmethods = InitMethods()
>         methods = {
>             'SiteNav_OpenTreeLevel': initmethods.init_opentreelevel(),
>             'SiteNav_LinkTreeItem': initmethods.init_linktreeitem(),
>             'SiteNav_ActiveTreeItem': initmethods.init_activetreeitem(),
>             'SiteNav_CloseTreeLevel': initmethods.init_closetreelevel(),
>             'local_css': initmethods.init_localcss()
>             }
>         for (methodname,method) in methods.items():
>             self.createDTMLMethod(methodname, '',method)
> 

hmm let's see.

map(lambda item: self.createDTMLMethod(item[0], '', item[1]), methods.items())

should do the trick.  Sure it isn't pretty (-:  What is wrong with the explicit
for loop?





More information about the Python-list mailing list