attrcheck

A simple attribution checker implemented as a decorator
Download

attrcheck Ranking & Summary

Advertisement

  • Rating:
  • License:
  • ISC License
  • Publisher Name:
  • Jun Namikawa
  • Publisher web site:
  • https://github.com/jnamika/

attrcheck Tags


attrcheck Description

A simple attribution checker implemented as a decorator attrcheck is a Python module that 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=, y=, z=dir(list)) >>> def foo(x, y, z=[]): passThe 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 AttributeErrorIn addition, attrcheck can check default argument values. Thus, the following code throws AttributeError. >>> @attrcheck(y=dir(str)) >>> def bar(x, y=[]): pass Requirements: · Python


attrcheck Related Software