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:

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

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

@register
@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

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”, http://www.ibm.com/developerworks/linux/library/l-cpdecor.html

Contact

You can contact the author, Charles Merriam, at charles.merriam@gmail.com. Or visit http://charlesmerriam.com

Repository

The source and bugs repository is git://github.com/merriam/dectools

Other Notes

This is a ‘shared experiment’ release.

This package depends on “decorator”, 3.1.2 or above, http://pypi.python.org/pypi/decorator/3.1.2

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

dectools-0.1.3.tar.gz (3.5 MB view details)

Uploaded Source

File details

Details for the file dectools-0.1.3.tar.gz.

File metadata

  • Download URL: dectools-0.1.3.tar.gz
  • Upload date:
  • Size: 3.5 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for dectools-0.1.3.tar.gz
Algorithm Hash digest
SHA256 d8b685475ac05296dd1ff4261d5d1a52265f5761083a2aeaf26f1cc409687e20
MD5 a683347a1f4a77d0db073761b124cbcc
BLAKE2b-256 e1ad0cb286b87f17e3db0b93ae76aa0280b34945493292223c35393d38b22414

See more details on using hashes here.

Supported by

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