It can be helpful to be able to handle functions/methods that have not been implemented. This is often done by having them print a string (such as "Not Implemented") and returning. This is a bit clumsy and one needs to edit it out when the function is ready to test.
As an alternative, I sometimes use a decorator. The decorator depends on having the last line of the function body be "pass".
If the last line is "pass", the function body is not executed even if the function includes code ahead of the "pass" line. Instead, a "not implemented" message is printed. Once that last line has been removed, the function body will get executed as if the decorator were not present.
import inspect
def notImplemented(f):
"""Decorator to announce when the decorated function
has not been implemented.
The last line of the function must be "pass" for this
to work. If the last line is "pass", the function will
not be invoked even if there is other code before
the "pass" line.
"""
_name = f.__name__
def new_f(*args):
_lines = inspect.getsourcelines(f)[0]
if _lines[-1].strip() == 'pass' :
print('%s() not implemented' % _name)
else:
return f(*args)
return new_f
**keywords could be added to the signatures, but so far I haven't needed it.