|
Project Information
Members
Featured
Wiki pages
|
The anntools package provides various modules to take advantage of Python 3.0's new function annotation feature. It supports validation, conversion and type checking of parameters passed to functions and their return values. It is useful for adding security checks and make your code more readable. This package is useful for Python 2.4 and up, since all functionality are provided as keyword arguments for decorators as well. Quick example: Validation For Python 2.4-2.6: @validate(Unicode, n=Int)
def myfunc(n):
return u'#'*nFor Python 3.0: @validate
def myfunc(n:Int) -> Str:
return '#'*nFor Python 3.0 with limits: @validate
def myfunc(n:Int(min=1, max=10)) -> Str(maxlen=10):
return '#'*n
|