Strong typing implementation for Python

edmondo.giovannozzi at gmail.com edmondo.giovannozzi at gmail.com
Mon Oct 12 12:21:46 EDT 2015


Il giorno lunedì 12 ottobre 2015 10:51:50 UTC+2, John Michael Lafayette ha scritto:
> 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
> 
> <johnmicha... 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

As far as I know the shell (if I can call it a shell) IPython has a sort of autocomplete. Given an object, after a dot if you type a tab it will give you the list of all the method that it can retrieve from the function dir(). 

geany, and spyder have also a sort of autocomplete.




More information about the Python-list mailing list