Skip to main content
Python Software Foundation 20th Year Anniversary Fundraiser  Donate today!

A simple attribution checker implemented as a decorator

Project description

attrcheck: attribution checker

This module provides a simple attribution checker implemented as a decorator. All functionality are provided as keyword arguments of the decorator.

Sample example of usage is following:

>>> from attrcheck import attrcheck
>>> @attrcheck(x=['real'], y=['index', 'strip'], z=dir(list))
... def foo(x, y, z=[]): pass

The code above means the following:

>>> def foo(x, y, z=[]):
...     if not hasattr(x, 'real'):
...         raise AttributeError
...     if not hasattr(y, 'index'):
...         raise AttributeError
...     if not hasattr(y, 'strip'):
...         raise AttributeError
...     for name in dir(list):
...         if not hasattr(z, name):
...             raise AttributeError

In addition, attrcheck can check default argument values. Thus, the following code throws AttributeError.

>>> @attrcheck(y=dir(str))
... def bar(x, y=[]): pass

Project details


Download files

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

Files for attrcheck, version 0.1.2
Filename, size File type Python version Upload date Hashes
Filename, size attrcheck-0.1.2-py2.7.egg (5.8 kB) File type Egg Python version 2.7 Upload date Hashes View
Filename, size attrcheck-0.1.2-py3.2.egg (5.8 kB) File type Egg Python version 3.2 Upload date Hashes View
Filename, size attrcheck-0.1.2.tar.gz (2.4 kB) File type Source Python version None Upload date Hashes View

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring DigiCert DigiCert EV certificate Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page