Skip to main content

Decorator toolkit library

Project description

DecTools provides a library of tools for creating Python decorators. It unifies usage between class decorators, decorators requiring arguments, and simple decorators. It also provides correct names, doc, and function signatures for decorated functions. Typical usage often looks like this:

def register_callback(function):
      gui.callback_create(function.__name__, function)

def require_login(function, args, kwargs, page_name):
     while not current_user_id():

@require_login("Summary of Items")
def view_summary():

This release has @make_call_(once/before/after/instead). It also has commonly used decorators in this release, including:

  • @pre, @post for pre and post condition processing

  • @log() for logging function calls

  • @invariant, a class decorator, for contract programming


Thanks to Michele Simionato for exposing utility functions in Decorator Decorator and to David Mertz for his excellent IBM Developer Works article “Charming Python: Decorators make magic easy”,


You can contact the author, Charles Merriam, at Or visit

Other Notes

This is a ‘shared experiment’ release.

This package depends on “decorator”, 3.1.2 or above,

Project details

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page