One use is to define a "stub" class or method that has a name but doesn't do anything. Maybe the most common case of this is to define a custom Exception class:
class MyCustomException(Exception):
pass
Now you can raise and catch exceptions of this type. The class exists only to be raised and caught, and doesn't need any behavior associated with it.
In similar fashion, APIs may include "do-nothing" functions that are meant to be overridden in subclasses:
class SomeComplexAPI(object):
# This method may be overridden in subclasses, but the base-class implementation is a no-op
def someAPIHook(self):
pass
If you didn't define the method at all, SomeComplexAPI().someAPIHook()
would raise an exception because the method doesn't exist. Defining it with pass
makes sure you can safely call it even if it doesn't do anything.