I often find myself writing if / elif / else constructs in python, and I want to include options which can occur, but for which the corresponding action is to do nothing. I
If you need a function that behaves as a nop, try
nop = lambda *a, **k: None nop()
Sometimes I do stuff like this when I'm making dependencies optional:
try: import foo bar=foo.bar baz=foo.baz except: bar=nop baz=nop # Doesn't break when foo is missing: bar() baz()