Is there a map without result in python?

前端 未结 15 1091
北恋
北恋 2020-12-03 04:33

Sometimes, I just want to execute a function for a list of entries -- eg.:

for x in wowList:
   installWow(x, \'installed by me\')

Sometime

15条回答
  •  不思量自难忘°
    2020-12-03 05:26

    I can not resist myself to post it as separate answer

    reduce(lambda x,y: x(y, 'installed by me') , wowList, installWow)
    

    only twist is installWow should return itself e.g.

    def installWow(*args):
        print args
        return installWow
    

提交回复
热议问题