Python Sanity Proposal: Type Hinting Solution

Chris Angelico rosuav at gmail.com
Fri Jan 23 12:11:18 EST 2015


On Sat, Jan 24, 2015 at 12:23 AM, Fetchinson .
<fetchinson at googlemail.com> wrote:
> In any case, I'm pretty sure it was said before, but I can't really
> find it anywhere, can someone tell me what the rationale is for
> *function signature* type hinting?
>
> I totally get type hinting in general, but why does it have to be in
> the function signature? Any reason for that specifically?

Is there any particular reason for the number of arguments to be part
of the function signature? I totally get the notion of declaring how
many arguments a function takes, but why does it have to be in the
function signature?

Data types are just as much a part of that signature as argument count
is. You could argue that the function's return type isn't part of
that, but that's about it.

> If there is a pep for it, people will use it, so the fact that
> it is optional is irrelevant...

Function annotations were introduced in 2006 (Python 3.0) with PEP 3107:

https://www.python.org/dev/peps/pep-3107/

They were optional then, they are still optional now. Have you been
overrun with them for the past decade? If not, why do you expect now
to be?

ChrisA



More information about the Python-list mailing list