Strong typing implementation for Python

Steven D'Aprano steve at pearwood.info
Mon Oct 12 07:39:02 EDT 2015


On Mon, 12 Oct 2015 07:47 pm, John Michael Lafayette wrote:

> Now that Python has static type checking 

It certainly does not. It appears you have misunderstood the purpose and
meaning of PEP 484.

PEP 484 provides a *standard meaning for function annotations* as
type-hints, which may be useful for third-party type-checking,
documentation generators, runtime inspection, editor auto-completion, and
other tools. It doesn't add static type checking to Python.


> and support for IDE auto-complete (PEP 484?), 

PEP 484 isn't needed for IDE auto-completion, although it can be used for
that.

Using IDLE and Pyton 2.7, I can type "l" (without the quotes) and TAB, and
IDLE will pop up a menu with "len" highlighted. And IDLE is a pretty basic
IDE: its auto-complete only works on built-in names, which makes it quite
limited. More powerful IDEs have better auto-complete features.


> I beg you to please use it. In your standard library, in your 
> production code, in everywhere. I cannot type without auto-complete.

I'm sorry for your disability, but for most programmers, auto-complete is a
convenience, not a necessity.


> 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.

I cannot imagine filling my mind with such useless information as "the
number of characters I have to type for auto-complete to guess the variable
name". I *especially* cannot fathom why I would prefer to learn "two
characters, starts with Da" by rote instead of something *meaningful*
like "DatagramSocket". What does "Da" stand for? Daddy, dabbling,
dandelion, dandruff, daguerreotype?


> 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. 

Hardly.


> 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.

No, it just eliminates learning. The end result is that you are reliant on
the auto-complete because you haven't actually learned.


> 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.

As I said, you don't need PEP 484 to implement auto-complete.

Auto-complete is a fine and useful tool. But if you are crippled as a
programmer without it, well, then you can hardly claim to understand the
language or framework you are programming in if you cannot use it without
an IDE doing half the work for you.



-- 
Steven




More information about the Python-list mailing list