What's a standard way to do a no-op in python?
Use pass for no-op:
if x == 0:
pass
else:
print "x not equal 0"
And here's another example:
def f():
pass
Or:
class c:
pass
How about pass
?
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()