I sometimes find myself wanting to make placeholder \'do nothing\' lambda expressions, similar to saying:
def do_nothing(*args):
pass
B
In Python 3 you don't even need to define any functions for that. Calling type(None)
will return you the NoneType
constructor, which you can use for doing nothing: type(None)()
. Keep in mind that the NoneType
constructor only takes 0 arguments.
In Python 2, though, creating instances of NoneType
is impossible, so lambda: None
would make the most sense.