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.
Examples and documentation
Quick example: Validation
For Python 2.4-2.6:
return u'#'*nFor Python 3.0:
def myfunc(n:Int) -> Str:
return '#'*nFor Python 3.0 with limits:
def myfunc(n:Int(min=1, max=10)) -> Str(maxlen=10):
Copyright © 2013 Black Duck Software, Inc. and its contributors, Some Rights Reserved. Unless otherwise marked, this work is licensed under a Creative Commons Attribution 3.0 Unported License . Ohloh ® and the Ohloh logo are trademarks of Black Duck Software, Inc. in the United States and/or other jurisdictions. All other trademarks are the property of their respective holders.