[Python-ideas] Proposal: Use mypy syntax for function annotations
Nicholas Cole
nicholas.cole at gmail.com
Fri Aug 15 07:46:15 CEST 2014
On Thu, Aug 14, 2014 at 6:29 PM, Ethan Furman <ethan at stoneleaf.us> wrote:
> On 08/14/2014 09:01 AM, Sunjay Varma wrote:
>>
>>
>> Additionally, this approach can be used by documentation generators as
>> well and removes any duplication from the
>> function declaration and the docstring.
>>
>> Here's a taste of what that looks like:
>> class SimpleEquation(object):
>> def demo(self, a, b, c):
>> """
>> This function returns the product of a, b and c
>> @type self: SimpleEquation
>> :param a: int - The first number
>> :param b: int
>> :param c: int - The third number should not be zero and
>> should also
>> only be -1 if you enjoy carrots (this comment spans 2
>> lines)
>> :return: int
>> """
>> return a * b * c
>
>
>
> +1 I like this much more.
+1 from me as well.
I like this much, much more as well. It is simply far more readable
and easier on the eyes, especially for functions with complicated
definitions. This feels like something I would actually use, without
it being a burden.
I think it could also work very nicely for keyword arguments.
N.
More information about the Python-ideas
mailing list