A suitable 'do nothing' lambda expression in python?

后端 未结 5 1788
遥遥无期
遥遥无期 2020-12-25 09:05

I sometimes find myself wanting to make placeholder \'do nothing\' lambda expressions, similar to saying:

def do_nothing(*args):
    pass

B

5条回答
  •  渐次进展
    2020-12-25 10:03

    Sometimes lambda functions are used for data transformation, and in that case 'do nothing' means to return the input, i.e.

    lambda x: x

    To return none you can write

    lambda x: None

提交回复
热议问题