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:
@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
30 Day Summary Apr 20 2013 — May 20 2013
|
12 Month Summary May 20 2012 — May 20 2013
|
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.