Is there a map without result in python?

前端 未结 15 1147
北恋
北恋 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:33

    You might try this:

    filter(lambda x: installWow(x, 'installed by me') and False, wowList)
    

    That way, the return result is an empty list no matter what.

    Or you could just drop the and False if you can force installWow() to always return False (or 0 or None or another expression that evaluates false).

提交回复
热议问题