[BangPypers] Expressing meta-data about classes, methods, variables, parameters in python

Heshan Suriyaarachchi heshan.suri at gmail.com
Thu Apr 3 13:04:31 CEST 2008


>
> Hi Anand,

   This is what I exactly mean. This is the thing I want to do. I am now
using python 2.5.1 . So is
   there a way that I can do a thing like this in python 2.5.1 ( an
alternative way).

  Heshan Suriyaarachchi

>
>
> >>> def f(x : "an integer", y: "another integer") -> "Sum of x and y":
> ...     return x + y
> >>> f.__annotations__
> {'y': 'another integer', 'x': 'an integer', 'return': 'Sum of x and y'}
>
> The help() function returns the annotation plus the docstring now.
> >>> f.__doc__ = "A sum function"
> >>> help(f)
> Help on function f in module __main__:
>
> f(x: 'an integer', y: 'another integer') -> 'Sum of x and y'
>    A sum function
>
>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.python.org/pipermail/bangpypers/attachments/20080403/3121a1cf/attachment.htm 


More information about the BangPypers mailing list