Strong typing implementation for Python

John Michael Lafayette johnmichaelreedfas at gmail.com
Mon Oct 12 04:47:35 EDT 2015


Now that Python has static type checking and support for IDE auto-complete
(PEP 484?), I beg you to please use it. In your standard library, in your
production code, in everywhere. I cannot type without auto-complete.

I know that sounds ridiculous, but I have been coding on a daily basis for
the last four years and I cannot recall the last time I actually typed out
a variable or function name without auto-complete typing it for me. To me,
java.net.DatagramSocket isn't "DatagramSocket". It is "Da" + Ctrl + Space +
Enter (auto complete). I literally memorized the number of characters I
have to type for auto-complete to guess the variable name and then I only
type that many characters. For me, typing without auto-complete is like
doing surgery with a kitchen knife. It's messy and error prone and I make
lots of mistakes and have to try twice as hard to remember the actual names
of variables instead of just whatever they start with.

You don't understand because you actually know what all the function names
are and you don't have to constantly hover over them in auto-complete and
pull up their documentation to figure out how to use them. But I do. And
for me, without auto-complete, the learning process goes from actively
querying the IDE for one documentation after another to having to minimize
the IDE and Google search for each and every function and module that I"m
not familiar with. Auto-complete literally cuts the learning time by more
than half.

So please please please use PEP 484 to document all your standard library
functions. Not for static compilation. Not even for catching mistakes
caused by bad function input (although I like that). For Christ's sake, do
it for the auto-complete. I gave up on JavaScript in favor of TypeScript
for a reason god dammit.
On Oct 11, 2015 3:45 PM, "Matt Wheeler" <m at funkyhat.org> wrote:

> On 9 October 2015 at 17:26, John Michael Lafayette
> <johnmichaelreedfas at gmail.com> wrote:
> > I would like Python to have a strong typing feature that can co-exist
> with
> > the current dynamic typing system. Currently Python is like this:
> >
> >     var animal = Factory.make("dog")  # okay.
> >     var dog = Factory.make("dog")       # okay.
> >     var cat = Factory.make("dog")        # are you sure?
> >
> > I would like Python to also be able to also do this:
> >
> >     Animal a = Factory.make("dog")    # okay. Dog is Animal.
> >     Dog d = Factory.make("dog")         # okay. Dog is Dog.
> >     Cat c = Factory.make("cat")           # Runtime error. Dog is not
> Cat.
>
> Though it's intended for performance optimisation rather than simply
> static typing for static typing's sake, you could probably use Cython
> to achieve what you want...
>
> ...but then you might start to see the benefits of dynamic typing :)
>
>
> --
> Matt Wheeler
> http://funkyh.at
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20151012/0da321f5/attachment.html>


More information about the Python-list mailing list